<template>
  <el-container>
    <el-header height="36px">
      <header-title title="验工计价" />
    </el-header>
    <el-tabs
        v-model="activeName"
        type="border-card"
        @tab-click="handleClick(activeName)"
      >
      <el-tab-pane label="发起验工计价" name="1"  >
        <el-main class="mainDetails" style="padding:15px 25px 0px">
      <TCollapse title="项目信息" style="width:100%;">
        <div class="content-box">
          <table style=" text-align: left;">
            <tr>
              <td width="50%">
                <span id="parProName" style="width: 120px;">{{ topdetailData.SUB_PRJ_NAME }}</span>
                <span v-if="topdetailData.SUB_ORG_NAME" id="subProCode">-{{ topdetailData.SUB_ORG_NAME }}</span>
                <span v-if="topdetailData.SUB_PRJ_CODE" id="parProCode">【<span v-debounce="()=>skipPage(topdetailData.SUB_PRJ_CODE)" style="color: #53c7f8;cursor: pointer;">{{ topdetailData.SUB_PRJ_CODE }}</span>】</span>
              </td>
            </tr>
          </table>
        </div>
      </TCollapse>
      <!-- 发起验工计价 -->
      <TCollapse title="验工计价" style="width:100%;">
        <el-row :gutter="10" class="content-box marginBottom14" type="flex" justify="start">
          <el-col :span="1.5" style="line-height:25px;text-align: left;">
            <div id="messBox">下列服务编码还未返回预估单：{{ coding }}</div>
            <div class="colorRed">预估单未返回时请确认以下操作是否已完成：</div>
            <div class="colorRed">（1）请与地市商合岗确认对应的服务编码是否已经采购下单（选址费、赔补费、测绘费、工程签证类服务需【项目经理】跳转【商合交易系统】去下单，具体操作路径：PMS系统-【综合查询】-【选址/赔补/测绘/签证费下单】）</div>
            <div class="colorRed">（2）如果已下单，请项目经理到商合交易系统完成收货（操作路径：我的业务/我的账户/订单管理），收货之后系统会在1小时左右推送预估单到PMS。可在订单详情页查询最新推送状态（查看路径：查看/查看订单报账）。</div>
            <div class="colorRed">（3）不需要的服务模块可通过项目设计变更删除。操作手册请见【知识管理】平台，搜索“设计变更”。</div>
          </el-col>
        </el-row>

        <el-row :gutter="10" class="marginBottom14" type="flex" justify="end">
          <el-col :span="1.5">
            <!-- // 判断是否展示新增按钮 ->我的待办销项 urlForm.newBtnShow === '1' -->
            <el-button class="pms-button-primary" @click="skipPage(topdetailData.SUB_PRJ_CODE)">查看交易预估单推送情况</el-button>
            <el-button class="pms-button-primary" @click="newFun()">新增</el-button>
            <el-button class="pms-button-primary" @click="chargeAgainstFun()">冲销</el-button>
            <el-tooltip placement="top" :content="'点击全选框，可勾选所有未推送明细，批量推送'">
              <el-button class="pms-button-primary" @click="pushFun()">推送</el-button>
            </el-tooltip>
            <el-button class="pms-button-primary" @click="postFun()">修改</el-button>
            <el-button class="pms-button-primary" @click="delFun()">删除</el-button>
          </el-col>
        </el-row>
        <div class="content-box">
          <el-table
            ref="singleTable"
            :data="detailData"
            style="width: 100%"
            border
            :header-cell-style="{
              background: '#F5F5F5',
              color: '#333333'
            }"
            @select="select"
            @select-all="selectAll"
          >
            <el-table-column align="center" width="50" type="selection" />
            <el-table-column align="center" type="index" width="50" label="序号">
              <template slot="header" slot-scope="{ column }">
                <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="siteId" label="站址编码" :show-overflow-tooltip="true">
              <template slot="header" slot-scope="{ column }">
                <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="serviceCode" label="服务编码" :show-overflow-tooltip="true">
              <template slot="header" slot-scope="{ column }">
                <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="serviceName" label="服务名称" :show-overflow-tooltip="true">
              <template slot="header" slot-scope="{ column }">
                <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="supplier" width="90" label="供应商名称" :show-overflow-tooltip="true">
              <template slot="header" slot-scope="{ column }">
                <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="orderCode" label="订单编码" :show-overflow-tooltip="true">
              <template slot="header" slot-scope="{ column }">
                <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="contractCode" label="合同编码" :show-overflow-tooltip="true">
              <template slot="header" slot-scope="{ column }">
                <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="shNum" width="90" label="商合预占数" :show-overflow-tooltip="true">
              <template slot="header" slot-scope="{ column }">
                <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="price" width="80" label="单价(元)" :show-overflow-tooltip="true">
              <template v-if="scope.row.serviceCode" slot-scope="scope">{{ roundingFour(scope.row.price) }}</template>
              <template slot="header" slot-scope="{ column }">
                <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="spuUnitAcc" width="80" label="物料精度" :show-overflow-tooltip="true">
              <template slot="header" slot-scope="{ column }">
                <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="shMoney" width="80" label="商合预占金额(元)" :show-overflow-tooltip="true">
              <template v-if="scope.row.serviceCode" slot-scope="scope">{{ rounding( scope.row.shMoney) }}</template>
              <template slot="header" slot-scope="{ column }">
                <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="sumNum" width="80" label="累计验工数量" :show-overflow-tooltip="true">
              <template v-if="scope.row.serviceCode" slot-scope="scope">{{ roundingFour(scope.row.sumNum) }}</template>
              <template slot="header" slot-scope="{ column }">
                <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="sumMoney" width="80" label="累计验工金额(元)" :show-overflow-tooltip="true">
              <template v-if="scope.row.serviceCode" slot-scope="scope">{{ rounding(scope.row.sumMoney) }}</template>
              <template slot="header" slot-scope="{ column }">
                <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="surplusNum" width="80" label="可发起验工数量" :show-overflow-tooltip="true">
              <template slot="header" slot-scope="{ column }">
                <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
              </template>
            </el-table-column>
            <el-table-column v-if="false" align="center" prop="onlybe1FLAG" width="80" label="服务数量是否只为1" :show-overflow-tooltip="true">
              <template slot="header" slot-scope="{ column }">
                <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
              </template>
            </el-table-column>
            <!-- <el-table-column prop="siteId" width="80" label="类型" :show-overflow-tooltip="true" align="left" header-align="center">
                <template slot-scope="scope">{{ scope.row.siteId ? '预估单': '验工计价' }}</template>
              </el-table-column> -->
            <el-table-column align="center" prop="orderState" :formatter="orderStateDictionaries" width="80" label="订单状态">
              <template slot="header" slot-scope="{ column }">
                <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="currentInspectionNum" width="80" label="本期验工数量" :show-overflow-tooltip="true">
              <template v-if="!scope.row.serviceCode" slot-scope="scope">{{ roundingFour(scope.row.currentInspectionNum) }}</template>
              <template slot="header" slot-scope="{ column }">
                <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="currentInspectionMoney" width="80" label="本期验工金额(元)" :show-overflow-tooltip="true">
              <template v-if="!scope.row.serviceCode" slot-scope="scope">{{ rounding(scope.row.currentInspectionMoney) }}</template>
              <template slot="header" slot-scope="{ column }">
                <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="projectProGress" width="80" label="项目进度(%)">
              <template slot="header" slot-scope="{ column }">
                <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
              </template>
            </el-table-column>
            <el-table-column align="left" header-align="center" prop="payType" :formatter="payTypeDictionaries" width="80" label="付款类型" :show-overflow-tooltip="true">
              <template slot="header" slot-scope="{ column }">
                <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="isPush" :formatter="isPushDictionaries" width="80" label="推送状态">
              <template slot="header" slot-scope="{ column }">
                <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </TCollapse>
    </el-main>
      </el-tab-pane>
      <el-tab-pane label="设计监理费验工计价" name="2"  >
      <iframe :src="iframeurls" scrolling="no" width="100%" :height="iframeHeight"  frameborder="0" v-if="activeName==='2'"/>
    </el-tab-pane> 
    </el-tabs>
    <!-- 新增弹框内容 -->
    <el-dialog
      ref="newDialogRef"
      v-dialogDrag
      :close-on-click-modal="false"
      :title="ifNewPost"
      :visible.sync="dialogVisible"
      width="50%"
      modal
      class="pms-dialog"
      :before-close="handleColse"
      style="text-align: justify;"
    >
      <div v-if="cxMessBox" style="color:red;text-align:center;">
        <div>如果预估单有首付款且数量为0，那么全量冲销进度款时请先冲销首付款，再冲销进度款！</div>
      </div>
      <!-- <div v-if="messBox" style="color:red;text-align:center;">
        <div>当前设计清单已经没有该物资编码，请直接点击【保存】按钮。</div>
      </div>  12222版本废除 -->
      <!-- <el-form :model="form" label-width="120px" :rules="rules" class="pms-details" size="mini" :disabled="false" :inline="true"> -->
      <el-form ref="form" :inline="true" :model="form" class="pms-details pms-details-top" label-width="160px" size="mini" :rules="rules">
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="项目进度(%)" prop="projectProGress">
              <el-input v-model="form.projectProGress" :disabled="projectProGressShow" style="width:100%" @change="onValuechanged2($event)" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="付款类型">
              <el-select v-model="form.payType" :disabled="payTypeShow" style="width:100%" @change="onValuechangedPayType($event)">
                <el-option label="进度款" value="PROGRESSING" />
                <el-option label="首付款(含安全生产费)" value="FIRST" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="本期验工数量" prop="currentInspectionNum">
              <el-input v-model="form.currentInspectionNum" :disabled="currentInspectionNumShow" style="width:100%" @change="onValuechanged1($event)" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="本期验工金额(元)" class="clearfix search-flex-box pms-queryShow">
              <el-input v-model="form.currentInspectionMoney" :disabled="currentInspectionMoneyShow" style="width:100%" @change="onValuechanged($event)" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="累计验工数量">
              <el-input v-model="form.sumNum" :disabled="sumNumShow" style="width:100%" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="累计验工金额(元)">
              <el-input v-model="form.sumMoney" :disabled="sumMoneyShow" style="width:100%" />
            </el-form-item>
          </el-col>
        </el-row>
        <!-- <div class="forWid" style="padding: 5px">
          <el-form-item label="项目进度(%)：" prop="projectProGress">
            <el-input v-model="form.projectProGress" :disabled="projectProGressShow" @change="onValuechanged2($event)" />
          </el-form-item>
          <el-form-item label="付款类型：">
            <el-select v-model="form.payType" :disabled="payTypeShow" @change="onValuechangedPayType($event)">
              <el-option label="进度款" value="PROGRESSING" />
              <el-option label="首付款(含安全生产费)" value="FIRST" />
            </el-select>
          </el-form-item>
        </div>
        <div class="forWid" style="padding: 5px">
          <el-form-item label="本期验工数量：" prop="currentInspectionNum">
            <el-input v-model="form.currentInspectionNum" :disabled="currentInspectionNumShow" @change="onValuechanged1($event)" />
          </el-form-item>
          <el-form-item label="本期验工金额(元)：" class="clearfix search-flex-box pms-queryShow">
            <el-input v-model="form.currentInspectionMoney" :disabled="currentInspectionMoneyShow" @change="onValuechanged($event)" />
          </el-form-item>
        </div>
        <div class="forWid" style="padding: 5px">
          <el-form-item label="累计验工数量：">
            <el-input v-model="form.sumNum" :disabled="sumNumShow" />
          </el-form-item>
          <el-form-item label="累计验工金额(元)：">
            <el-input v-model="form.sumMoney" :disabled="sumMoneyShow" />
          </el-form-item>
        </div> -->
      </el-form>
      <div class="formBott">
        <el-button v-debounce="newSave" class="pms-button-primary" type="primary">保存</el-button>
        <el-button class="pms-button-primary" @click="close()">关闭</el-button>
      </div>
    </el-dialog>
    <!-- 新增弹框内容 ↑ -->

    <!-- 批量新增弹框内容 ↓ -->
    <el-dialog
      ref="newAllDialogRef"
      v-dialogDrag
      title="批量新增验工计价"
      :visible.sync="fomrDialogVisible"
      :before-close="handleColseTwo"
      width="90%"
      modal
      :close-on-click-modal="false"
      class="pms-dialog"
      style="text-align: justify;"
    >
      <el-table
        :data="detailFormData"
        style="width: 100%"
        border
        :header-cell-style="{
          background: '#F5F5F5',
          color: '#333333'
        }"
        :cell-style="styleBack"
        @cell-click="cellClick"
      >
        <!-- <el-table-column v-show="true" align="center" width="55" type="selection" /> -->
        <el-table-column align="center" type="index" width="50" label="序号">
          <template slot="header" slot-scope="{ column }">
            <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="siteId" label="站址编码" :show-overflow-tooltip="true">
          <template slot="header" slot-scope="{ column }">
            <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="serviceCode" label="服务编码" :show-overflow-tooltip="true">
          <template slot="header" slot-scope="{ column }">
            <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="serviceName" label="服务名称" :show-overflow-tooltip="true">
          <template slot="header" slot-scope="{ column }">
            <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="formPattern" label="服务规格" :show-overflow-tooltip="true">
          <template slot="header" slot-scope="{ column }">
            <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="supplier" label="供应商名称" :show-overflow-tooltip="true">
          <template slot="header" slot-scope="{ column }">
            <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="orderCode" label="订单编码" :show-overflow-tooltip="true">
          <template slot="header" slot-scope="{ column }">
            <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="contractCode" width="80" label="合同编码" :show-overflow-tooltip="true">
          <template slot="header" slot-scope="{ column }">
            <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="shNum" width="90" label="商合预占数" :show-overflow-tooltip="true">
          <template slot="header" slot-scope="{ column }">
            <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="price" width="80" label="单价(元)" :show-overflow-tooltip="true">
          <template v-if="scope.row.serviceCode" slot-scope="scope">{{ roundingFourAll(scope.row.price) }}</template>
          <template slot="header" slot-scope="{ column }">
            <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="shMoney" width="80" label="商合预占金额(元)" :show-overflow-tooltip="true">
          <template v-if="scope.row.serviceCode" slot-scope="scope">{{ roundingAll( scope.row.shMoney) }}</template>
          <template slot="header" slot-scope="{ column }">
            <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="sumNum" width="80" label="累计验工数量" :show-overflow-tooltip="true">
          <template v-if="scope.row.serviceCode" slot-scope="scope">{{ roundingFourAll(scope.row.sumNum) }}</template>
          <template slot="header" slot-scope="{ column }">
            <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="sumMoney" width="80" label="累计验工金额(元)" :show-overflow-tooltip="true">
          <template v-if="scope.row.serviceCode" slot-scope="scope">{{ roundingAll(scope.row.sumMoney) }}</template>
          <template slot="header" slot-scope="{ column }">
            <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
          </template>
        </el-table-column>
        <!-- <el-table-column align="center" prop="currentInspectionNum" width="50" label="1" />
        <el-table-column align="center" prop="currentInspectionMoney" width="50" label="2" /> -->
        <!-- <el-table-column align="center" prop="surplusNum" width="50" label="可发起验工数量" />
        <el-table-column align="center" prop="orderState" width="50" label="订单状态" />
        <el-table-column v-if="ifOperationTime" align="center" prop="operationTime" width="50" label="发起验工时间" />
        <el-table-column v-if="ifOperationUserName" align="center" prop="operationUserName" width="50" label="操作人" /> -->
        <el-table-column align="center" prop="currentInspectionNum" width="80" label="本期验工数量" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            <el-input v-if="scope.row.isOk" v-model="scope.row.currentInspectionNum" type="text" width="50" @blur="handleBlur(scope.row)" />
            <div v-else @click="handleEdit(scope.row)">{{ roundingFourAll(scope.row.currentInspectionNum) }}</div>
          </template>
          <template slot="header" slot-scope="{ column }">
            <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="currentInspectionMoney" width="80" label="本期验工金额(元)" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            <el-input v-if="scope.row.isOk2" v-model="scope.row.currentInspectionMoney" type="text" width="50" @blur="handleBlurTwo(scope.row)" />
            <div v-else @click="handleEditTwo(scope.row)">{{ roundingAll(scope.row.currentInspectionMoney) }}</div>
          </template>
          <template slot="header" slot-scope="{ column }">
            <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
          </template>
        </el-table-column>
        <!-- <el-table-column align="center" prop="currentInspectionNum" width="50" label="本期验工数量" @blue="handleEdit(scope)" @change="changeData(scope)" />
        <el-table-column align="center" prop="currentInspectionMoney" width="50" label="本期验工金额(元)" /> -->
        <el-table-column align="center" prop="projectProGress" width="70" label="项目进度(%)" :show-overflow-tooltip="true">
          <template slot="header" slot-scope="{ column }">
            <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
          </template>
        </el-table-column>
        <el-table-column align="left" header-align="center" prop="payType" :formatter="payTypeDictionaries" width="80" label="付款类型" :show-overflow-tooltip="true">
          <template slot="header" slot-scope="{ column }">
            <el-tooltip effect="dark" :content="column.label" placement="top"><div class="header-tooltip">{{ column.label }}</div></el-tooltip>
          </template>
        </el-table-column>
        <!-- <el-table-column align="center" prop="isPush" width="50" label="推送状态" /> -->
      </el-table>
      <div class="formBott">
        <el-button type="primary" class="pms-button-primary" @click="allSave()">保存</el-button>
        <el-button class="pms-button-primary" @click="closeTwo()">关闭</el-button>
      </div>
      <!-- <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
      </span> -->
    </el-dialog>
    <!--批量 新增弹框内容 ↑ -->
  </el-container>
</template>
  <script>
  // 系统常量配置
  // import * as Axios from '@/api/checkoutValuation'
  import {
    getServiceReceInspection,
    getConfigInfo,
    queryInsValDetails,
    getChilAndParPrjInfo,
    selectExistServNew,
    insValProPushNew,
    ifEngineeringVisaNew,
    getCheckInsVaDataNew,
    updateInsVaDetailsNew,
    getMaterialInfoNew,
    getCheckIsPushNumNew,
    getSumLossByVidNew,
    getShopTokenAndUrlNew
  } from '@/api/checkoutValuation/solovecheck/checkOne'
  import HeaderTitle from '@/components/basic/HeaderTitle'
  import TCollapse from '@/components/basic/TCollapse.vue'
  import { disableScroll, enableScroll } from '@/utils'
  import $ from 'jquery'

  export default {
    name: 'FileList',
    components: {
      HeaderTitle,
      TCollapse
    },
    props: {
        urlForm: {
            type: Object,
            default: () => ({})
        }
    },
    data() {
      return {
        // 按钮控制可点
        activeNames: ['demo1', 'demo2'],
        // 校验用的处理数据
        yuGuDanArr: [],
        yanGongArr: [],
        // 新增&批量新增
        selectionVal: [], // 复选框存放的数据
        newAllVal: 1, // 1是新增,2是批量新增
        dialogVisible: false, // 新增弹框默认不展示
        ifNewPost: '新增验工计价',
        fomrDialogVisible: false, // 批量新增弹框默认不展示
        detailFormData: [], // 批量新增存放的数据
        isValid: true, // 批量新增校验
        oldCspectionNum: '', // 原始的本期验工数量
        oldCspectionMoney: '', // 原始的本期验工金额
        form: {
            projectProGress: '', // 项目进度
            payType: 'PROGRESSING', // 付款类型
            currentInspectionNum: '', // 本期验工数量
            currentInspectionMoney: '', // 本期验工计价金额
            sumNum: '', // 累计验工数量
            sumMoney: '' // 累计验工计价金额
        },
        formIfType: '0', // 1的时候为修改和删除,0为其他
        editType: '1', // 1是新增 2冲销
        flagVal: '1', // flag 新增 冲销传1 修改传2
        currentDataCurrentInspectionNum: '', // 修改 时获取当前数据的累计验工数量
        currentDataCurrentInspectionMoney: '', // 修改 时获取当前数据的累计金额
        sign: false, // 添加前是否已存在项目进度为100%的数据    true有   false没有
        floataMountMax: '', // FLOATAMOUNT_MAX 上下浮动金额
        sunmNumMin: '', // 数量百分比
        // 冲销时候用的变量
        prjId: '', // prjId
        newOldProject: '', // 0是新项目,1是老项目
        firstNum: '',
        firstMoney: '',
        rules: {
            projectProGress: [{ required: true, pattern: /^100$|^(\d|[1-9]\d)(\.\d{1,4})*$/, message: '数字必须在0-100之间', trigger: 'change' }],
            currentInspectionNum: [{ required: true, pattern: /^(\-)?\d+(\.\d+)?$/, message: '请输入数字', trigger: 'change' }]
        },
        cxMessBox: false, // 文字默认不提示
        messBox: false, // 文字默认不提示
        projectProGressShow: false, // 项目进度：默认验工计价金额可展示
        payTypeShow: true, // 付款类型：默认不可选进度款
        currentInspectionNumShow: false, // 本期验工数量：默认验工计价金额可展示
        currentInspectionMoneyShow: true, // 本期验工计价金额：默认验工计价金额不可展示
        sumNumShow: true, // 累计验工数量：本期验工计价金额：默认验工计价金额不可展示
        sumMoneyShow: true, // 累计验工计价金额：本期验工计价金额：默认验工计价金额不可展示
        detailData: [], // 页面请求存放的数据
        coding: [],
        getServeCodeData: [], // 储存根据验工计价获取对应服务编码信息
        postOldCurrNum: '', // 存放当前这条数据的本期验工数量
        postOldCurrMony: '', // 存放当前这条数据的本期验工金额
        xiugaiValu: '', // 修改保存校验 (冲销特殊校验)
        oldSumMoney: '', // 11-20
        oldSumNum: '', // 11-20
        topdetailData: '',
        // 有没有用不知道
        addSumMoney2: '',
        activeName: '1',
        iframeurls:"",
        iframeHeight:''
      }
    },
    created() {
      console.log('GET', sessionStorage.getItem('china-tower-token-pms20'), '🚗')
        this.prjId = this.urlForm.prjId
        this.newOldProject = this.urlForm.newOldProject
        this.listData()
        // 公共的查询哪些服务编码没有返回预估单
        getServiceReceInspection({ prjId: this.prjId }).then(res => {
            if (res.code === '200' && res.data.length > 0) {
                res.data.map((v) => {
                    this.coding.push(v)
                })
                this.coding = this.coding.join(',') + '。'
            } else if (res.data.length === 0) {
              this.coding = '无。'
            } else {
              console.log('[]')
            }
        })
        // 获取验工计价配置信息
        getConfigInfo({ prjId: this.prjId }).then(res => {
          if (res.code === '200') {
            this.floataMountMax = Number(res.data.FLOATAMOUNT_MAX) // FLOATAMOUNT_MAX 上下浮动金额
            this.sunmNumMin = Number(res.data.SUMNUM_MIN) // 数量百分比
            // this.flowNumUMax = Number(res.data.FLOWNUM_MAX) // 流程次数
          }
      })
       // 头部信息 和 项目编码
       this.topListData()
       this.getSoftHeight()
    },
    mounted() {
        // console.log(this.$route)
    },
    methods: {
      handleClick(){
        console.log(1);
      },
      getSoftHeight() {
        const {prjId,newOldProject,manageMode} = this.$route.query
        this.iframeurls = `${process.env.VUE_APP_ZHONGRUAN_URL}designSupervisionDetail?prjId=${prjId}&newOldProject=${newOldProject}&manageMode=${manageMode}&spcalTag=todo`
        window.addEventListener('message', (event) => {
          const base_url = ''
          if (event.origin === base_url) {
            return
          }
          // 获取高度
          if (event.data.type === 'getSoftTabHeight') {
            this.iframeHeight = event.data.height
            this.$emit('initIframeHeight', event.data.height)
          }
        })
      },
      rounding(value) {
        return this.newOldProject === '1' ? Number(value).toFixed(2) : value
      },
      roundingFour(value) {
        return this.newOldProject === '1' ? Number(value).toFixed(4) : value
      },
      roundingAll(value) {
        return Number(value).toFixed(2)
      },
      roundingFourAll(value) {
        return Number(value)
      },
      // 初始化列表数据
      async listData() {
        this.selectionVal = []
        const { code, data } = await queryInsValDetails({ prjId: this.prjId })
        if (code === '200') {
          this.detailData = data
        }
      },
      async topListData() {
          const { code, data } = await getChilAndParPrjInfo({ subPrjId: this.prjId })
          if (code === '200') {
              if (data) {
                this.topdetailData = data
              }
          }
      },
      // 推送状态字典转换
      isPushDictionaries(row) {
        switch (row.isPush) {
            case '9':
            return '未推送'
            case '0':
            return '未推送'
            case '1':
            return '已推送'
            case '2':
            return '推送超时'
            case '3':
            return '部分推送'
            default:
            break
        }
      },
      // 付款类型字典转换
      payTypeDictionaries(row) {
        switch (row.payType) {
            case 'FIRST':
            return '首付款(含安全生产费）'
            case 'PROGRESSING':
            return '进度款'
            case 'LOSS':
            return '损失款'
            default:
            break
        }
      },
      // 订单状态字典转换
      orderStateDictionaries(row) {
        switch (row.orderState) {
            case '1':
            return '有效'
            case '0':
            return '无效'
            case '-1':
            return '冻结'
            default:
            break
        }
      },
      // 综合查询-项目操作-验工计价-复选框 判断条件
      selectAll(selection) {
        if (selection.length === 0) {
            this.selectionVal = []
        } else {
            this.selectionVal = selection
        }
      },
      // 单选
      select(selection, row) {
          this.selectionVal = selection
          if (this.selectionVal.length > 0) {
            this.currentDataCurrentInspectionNum = this.selectionVal[0].currentInspectionNum
            this.currentDataCurrentInspectionMoney = this.selectionVal[0].currentInspectionMoney
          }
      },
      // 验工计价-综合查询-项目操作-校验
      newVerify() { // 新增:全选&&未全选
        // this.select()
        if (this.$refs['singleTable'].store.states.isAllSelected === false) {
            // this.selectionVal.length = []
            if (!this.selectionVal.length) {
                // this.$message({
                //     message: '请选择某条预估单或验工计价结果',
                //     type: 'warning'
                // })
                return '1'
            }
        }
      },
      AllVerify() { // 推送,冲销,修改,删除:全选&&未全选
        if (this.$refs['singleTable'].store.states.isAllSelected === false) {
            if (!this.selectionVal.length) {
                // this.$message({
                //     message: '请选择某条预估单或验工计价结果',
                //     type: 'warning'
                // })
                return '1'
            }
        } else {
            // this.$message({
            //     message: '支持对预估单发起批量新增操作，暂不支持其他操作',
            //     type: 'warning'
            // })
            return '2'
        }
      },
      filtrationSelectingData() { // 推送,冲销,修改,删除:全选&&未全选
            this.selectionVal.map(v => {
                if (v.serviceCode !== null) {
                    this.yuGuDanArr.push(v)
                }
            })

            this.selectionVal.map(v => {
                if (v.serviceCode == null) {
                    this.yanGongArr.push(v)
                }
            })
      },
      // 批量新增携带处理数据
      AllNewPageOpen() {
          this.fomrDialogVisible = true // 批量新增验工计价展示
          // this.dialogEl('newAllDialogRef') // 外部打开弹框
          // 获取所有数据 进度为100的子项目 ↓
          var oldValeArr = []
          this.detailData.map(oldVale => {
            console.log(oldVale.projectProGress, 'oldVale.projectProGress')
            if (oldVale.projectProGress === '100') {
              oldValeArr.push(oldVale)
            }
          })
          var result = [] // 存放批量新增过滤数据
          for (let i = 0; i < this.yuGuDanArr.length; i++) {
              let isExist = false
              for (let j = 0; j < oldValeArr.length; j++) {
                if (this.yuGuDanArr[i].vid === oldValeArr[j].pid) {
                  isExist = true
                  break
                  }
              }
              if (!isExist) {
                  result.push(this.yuGuDanArr[i])
              }
          }
          // this.yanGongArr.PROJECTPROGRESS 父亲.vid == 子.pid
          // 获取所有数据 进度为100的子项目↑
          this.detailFormData = result.map(newVal => {
              newVal.currentInspectionNum = newVal.shNum - newVal.sumNum
              newVal.currentInspectionMoney = newVal.shMoney - newVal.sumMoney
              newVal.projectProGress = '100'
              newVal.payType = 'PROGRESSING'// 付款类型
              return newVal
            })
        },
      // // 获取当前为新项目
      // getAllPayType() {
      //   var getAllPayTypeValArr = []
      //   var getAllPayTypeTwoValArr = []
      //       this.detailData.map(v => {
      //         if (v.pid === this.yuGuDanArr[0].vid) {
      //           getAllPayTypeValArr.push(v)
      //         }
      //       })
      //       console.log(this.newOldProject )
      //   if (this.newOldProject === '0') { // 获取当前为新项目 并且里面验工计价结果 有首付款的
      //     getAllPayTypeValArr.map(v => {
      //       console.log(v)
      //       if (v.payType === 'FIRST') {
      //         getAllPayTypeTwoValArr.push(v)
      //       }
      //     })
      //   }
      //   return getAllPayTypeTwoValArr.length
      // },
      async newFunrepairOne() {
        if (this.newVerify() === '1' || this.yanGongArr.length > 1 || this.yanGongArr.length === 1) { // 新增:全选&&未全选  || 多选某条验工计价结果时 ||  选择一条验工计价时的提示
            this.$message({
                message: '请选择一条或多条预估单进行新增操作',
                type: 'warning'
            })
            return Promise.reject()
        }
        if (this.yuGuDanArr.length > 1 || (this.yanGongArr.length > 0 && this.yuGuDanArr.length > 0)) {
            this.AllNewPageOpen() // 批量新增
            return Promise.reject()
        }
      },
      async newFunrepairTwo() {
        if (this.yuGuDanArr[0].pid === '0' && this.yuGuDanArr[0].orderState === '1' && this.yuGuDanArr[0].ifAdd === '1') {
          // console.log('订单有效状态下并且已经有首付款（含安全生产费）信息显示新增验工计价')
        } else {
          this.$message({
            message: '仅支持对订单状态为“有效”的预估单发起新增操作',
            type: 'warning'
          })
          return Promise.reject()
        }
      },
      async newFunrepairThree() {
        return this.yuGuDanArr.length === 1 && this.yanGongArr.length === 0
      },
      // 验工计价-综合查询-项目操作-新增 & 批量新增
      async newFun() {
        this.ifNewPost = '新增验工计价'
        this.editType = '1'
        this.flagVal = '1'
        this.payTypeShow = true
        this.cxMessBox = false
        this.projectProGressShow = false
        this.currentInspectionNumShow = false

        this.yuGuDanArr = [] // 先清空
        this.yanGongArr = [] // 先清空
        this.filtrationSelectingData()
        await this.newFunrepairOne()
        if (this.newFunrepairThree()) {
           await this.newFunrepairTwo()
            this.formIfType = '0' // 保存时传的值
            var fuZiArr = []
            this.detailData.map(v => {
              if (v.pid === this.yuGuDanArr[0].vid) {
                fuZiArr.push(v)
              }
            })
            for (var i = 0; i < fuZiArr.length; i++) { // 进度100 且 付款类型为首付款的时候 sign =true
              if (fuZiArr[i].projectProGress === '100' && fuZiArr[i].payType === 'PROGRESSING') {
                this.sign = true
              }
            }
            await this.newProjectFomr()
            // if (this.messBox) {
            //   this.form = {
            //       payType: 'PROGRESSING' // 付款类型
            //   }
            //   this.$message({
            //       message: '当前设计清单中已不存在该服务编码，不允许新增验工计价，如有已推送验工计价，请进行冲销操作!',
            //       type: 'warning'
            //   })
            //   return
            // }
            this.dialogVisible = true // 新增页面打开
            // this.dialogEl('newDialogRef') // 外部打开弹框
            return
        }
      },
      // 新增校验当前设计清单已经没有该物资编码
      async newProjectFomr() {
        // if (this.selectionVal[0].onlybe1FLAG === 'Y') {
        //   this.form.currentInspectionNum = 1
        //   this.currentInspectionNumShow = true
        //   this.form.sumNum = 1
        //   this.sumNumShow = true
        //   this.sumMoneyShow = true
        // } else {
          this.currentInspectionMoneyShow = true
          this.sumNumShow = true
          this.sumMoneyShow = true
        // }
        var prjId = this.selectionVal[0].prjId // 项目ID
        var subPrjId = this.selectionVal[0].subPrjId // 子项目ID
        var serviceCode = this.selectionVal[0].serviceCode
        // { prjId: '30000887', subPrjId: '30000888', serviceCode: '9030010305000000000545' }
        if (this.editType === '1') {
          const selectExistServ = await selectExistServNew({ prjId: prjId, subPrjId: subPrjId, serviceCode: serviceCode })
          if (selectExistServ.code === '200') {
            if (selectExistServ.data.length === 0) {
              this.messBox = true
              // this.form.currentInspectionNum = 0
              // this.currentInspectionNumShow = true
              // this.form.currentInspectionMoney = 0
              // this.currentInspectionMoneyShow = true
              // this.form.projectProGress = 100
              // this.projectProGressShow = true
              // this.form.sumNum = this.selectionVal[0].sumNum
              // this.form.sumMoney = this.selectionVal[0].sumMoney
            }
          }
        }
       },
       async chargeAgainstFunrepairOne() {
        if (this.AllVerify() === '1' || this.AllVerify() === '2') { // 推送,冲销,修改,删除:全选&&未全选
            this.$message({
                message: '请选择一条预估单进行冲销操作',
                type: 'warning'
            })
            return Promise.reject()
        }
       },
       async chargeAgainstFunrepairTwo() {
        if (this.yuGuDanArr.length > 1 || (this.yanGongArr.length > 0 && this.yuGuDanArr.length > 0)) {
            this.$message({
                message: '请选择一条预估单进行冲销操作',
                type: 'warning'
            })
            return Promise.reject()
        }
        if (this.yanGongArr.length > 1 || this.yanGongArr.length === 1) { // 选择一条预估单|| 选择一条验工计价时的提示
            this.$message({
                message: '请选择一条预估单进行冲销操作',
                type: 'warning'
            })
            return Promise.reject()
        }
       },
       async chargeAgainstFunrepairThree() {
        if (this.yuGuDanArr[0].pid === '0' && this.yuGuDanArr[0].orderState === '1' && this.yuGuDanArr[0].ifAdd === '1') {
            // onsole.log('执行')
          } else {
            this.$message({
                  message: '仅支持对订单状态为“有效”的预估单发起冲销操作',
                  type: 'warning'
              })
              return Promise.reject()
          }
       },
       async chargeAgainstFunrepairFour() {
        return this.yuGuDanArr.length === 1 && this.yanGongArr.length === 0
       },
       async chargeAgainstFunrepairFive() {
        if (this.newOldProject === '1') { // 老项目
             this.payTypeShow = false
           }
       },
      // 验工计价-综合查询-项目操作-冲销
     async chargeAgainstFun() {
        this.flagVal = '1'
        this.editType = '2'
        this.cxMessBox = true
        this.projectProGressShow = false
        this.currentInspectionNumShow = false
        await this.chargeAgainstFunrepairOne()
        this.yuGuDanArr = [] // 先清空
        this.yanGongArr = [] // 先清空
        this.filtrationSelectingData()
        await this.chargeAgainstFunrepairTwo()
        if (this.chargeAgainstFunrepairFour()) {
          await this.chargeAgainstFunrepairThree()
          this.ifNewPost = '冲销验工计价'
           await this.chargeAgainstFunrepairFive()
            var fuZiArr = []
            this.detailData.map(v => {
              if (v.pid === this.yuGuDanArr[0].vid) {
                fuZiArr.push(v)
              }
            })
            for (var i = 0; i < fuZiArr.length; i++) {
              if (fuZiArr[i].projectProGress === '100' && fuZiArr[i].payType === 'PROGRESSING') {
                this.sign = true
              }
              if (fuZiArr[i].payType === 'FIRST') {
                this.firstNum = fuZiArr[i].currentInspectionNum
                this.firstMoney = fuZiArr[i].currentInspectionMoney
              }
            }
            this.formIfType = '0' // 保存时传的值
            this.dialogVisible = true // 冲销页面打开
            // this.dialogEl('newDialogRef') // 外部打开弹框
            return
        }
      },
      // 2024/10/25验工计价支持批量推送
      batchSendData() {
        const type1 = ['FIRST', 'PROGRESSING']
        const type2 = ['0', '2']
        const type3 = ['1']
        if (this.selectionVal.length === 0) {
          this.$message({
            message: '请勾选数据',
            type: 'warning'
          })
          return Promise.reject()
        }
        const _result = this.selectionVal.filter(v => v.serviceCode == null)
        for (let i = 0; i < _result.length; i++) {
          if (type1.includes(_result[i].payType) && type2.includes(_result[i].isPush) && type3.includes(_result[i].orderState)) {
            this.yanGongArr.push(_result[i])
          }
        }
        if (this.yanGongArr.length > 10) {
          this.$message({
            message: '最多勾选10条批量推送,请本次推送后再次勾选推送',
            type: 'warning'
          })
          // 刷新列表
          this.listData()
          return Promise.reject()
        }
        if (this.yanGongArr.length === 0) {
          this.$message({
            message: '不存在推送超时和未推送的验工计价明细，无需推送，请核实！',
            type: 'warning'
          })
          // 刷新列表
          this.listData()
          return Promise.reject()
        }
        console.log('过滤后符合条件的可推送', this.yanGongArr)
      },
      // 验工计价-综合查询-项目操作-推送商合
     async pushFun() {
       this.yuGuDanArr = [] // 先清空
       this.yanGongArr = [] // 先清空
       await this.batchSendData()
       await this.getNewPushFun()
            // await this.pushShFun()
            // if (this.AllVerify() === '1' || this.AllVerify() === '2') { // 推送商合,冲销,修改,删除:全选&&未全选
            //     this.$message({
            //         message: '请选择一条未推送或推送超时的验工计价结果进行推送操作',
            //         type: 'warning'
            //     })
            //     return
            // }
            // this.filtrationSelectingData()

            // if (this.yuGuDanArr.length > 1 || (this.yanGongArr.length > 1 && this.yuGuDanArr.length > 1)) {
            //     this.$message({
            //         message: '请选择一条未推送或推送超时的验工计价结果进行推送操作',
            //         type: 'warning'
            //     })
            //     return
            // }

            // if (this.yuGuDanArr.length === 1 || this.yanGongArr.length > 1) { // 选择一条预估单|| 选择一条验工计价时的提示
            //     this.$message({
            //         message: '请选择一条未推送或推送超时的验工计价结果进行推送操作',
            //         type: 'warning'
            //     })
            //     return
            // }

            // if (this.yanGongArr.length === 1 && this.yanGongArr[0].isPush === '1') { // 选中已推送的验工计价结果并点击【推送】按钮时
            //     this.$message({
            //         message: '当前验工计价已推送商合交易，无需重复推送',
            //         type: 'warning'
            //     })
            //     return
            // }

            // if (this.yanGongArr.length === 1) {
            //     this.pushShFun()
            //     return
            // }
      },
      async getNewPushFun() {
         // 获取父项目信息
        const parentNode = this.newSeltVal()
        // 当前点击的子项目信息
        const childrenList = this.yanGongArr.map(item => {
          return {
            subPrjId: item.subPrjId,
            serviceCode: item.serviceCode ? item.serviceCode : this.changeParentData(item, 'serviceCode'),
            orderNo: item.orderCode ? item.orderCode : this.changeParentData(item, 'orderCode'),
            vId: item.vid,
            type: Math.sign(this.yanGongArr[0].currentInspectionNum) === 1 ? '1' : '2',
            prjId: item.prjId
          }
        })
        const params = {
          prjId: parentNode[0].prjId,
          insValProPushVOList: childrenList
        }
        console.log(params, '推送参数')
        const { code, message } = await insValProPushNew(params)
        if (+code !== 200) {
          this.$message({
            message: message,
            type: 'error',
            dangerouslyUseHTMLString: true
          })
          this.listData()
          return
        }
        this.$message({
          message: message,
          type: 'success',
          dangerouslyUseHTMLString: true
        })
        this.listData()
      },
      changeParentData(item, type) {
        const result = this.detailData.filter(v => v.vid === item.pid)
        return result[0][type]
      },
      async pushShFun() {
        var record = this.yanGongArr[0] // 当前点击的子项目信息
        var parentNode = this.newSeltVal() // 获取父项目信息
        var typeVal = ''
        if (Math.sign(this.yanGongArr[0].currentInspectionNum) === 1) {
          typeVal = '1'
        } else {
          typeVal = '2'
        }
        if ((['0', '2'].includes(record.isPush)) && parentNode[0].orderState === '1' && (['PROGRESSING', 'FIRST'].includes(record.payType)) && record.orderState === '1') {
          // 订单状态有效且该条验工计价信息未推商合允许删除编辑  首付款（含安全生产费）不允许编辑
          // const gtIspectionVal = await Axios.inspectionValuationPush({ valuationDetailId: record.vid }) 1104替换新接口
          const obj = {
                    subPrjId: record.subPrjId,
                    serviceCode: parentNode[0].serviceCode,
                    vId: record.vid,
                    type: typeVal,
                    prjId: parentNode[0].prjId
                  }
          const insValProPush = await insValProPushNew(obj)
          if (insValProPush.code === '200') {
            this.$message({
                message: insValProPush.message,
                type: 'success'
            })
          }
          this.listData()
        } else {
          this.$message({
            dangerouslyUseHTMLString: true,
                  message: '支持推送符合以下条件的验工计价信息:<br/><br/>（1）验工结果推送状态为“推送超时”支持二次推送<br/><br/>（2）在预估单的订单状态和验工结果的付款类型为进度款或首付款的订单状态均为有效时且当前验工结果尚未推送',
                  type: 'warning'
            })
          return
        }
      },
      // 验工计价-综合查询-项目操作-修改
      postFun() {
        if (this.AllVerify() === '1' || this.AllVerify() === '2') { // 推送,冲销,修改,删除:全选&&未全选
            this.$message({
                message: '请选择一条未推送的验工计价进行修改操作',
                type: 'warning'
            })
            return
        }
        this.yuGuDanArr = [] // 先清空
        this.yanGongArr = [] // 先清空

        this.filtrationSelectingData()
        if (this.yuGuDanArr.length > 1 || (this.yanGongArr.length > 1 && this.yuGuDanArr.length > 1)) {
            this.$message({
                message: '请选择一条未推送的验工计价进行修改操作',
                type: 'warning'
            })
            return
        }

        if (this.yuGuDanArr.length === 1 || this.yanGongArr.length > 1) { // 选择一条预估单|| 选择一条验工计价时的提示
            this.$message({
                message: '请选择一条未推送的验工计价进行修改操作',
                type: 'warning'
            })
            return
        }

        if (this.yanGongArr.length === 1 && this.yanGongArr[0].isPush === '1') { // 选中已推送的验工计价结果并点击【修改】按钮时
            this.$message({
                message: '仅支持对推送状态为“未推送”且订单状态为“有效”的验工计价结果发起修改操作',
                type: 'warning'
            })
            return
        }

        if (this.yanGongArr.length === 1) {
          console.log(this.yanGongArr[0].currentInspectionNum, 'this.yanGongArr[0].currentInspectionNum')
          this.xiugaiValu = '1' // 传个1 证明走修改了
          if (this.yanGongArr[0].currentInspectionNum > 0) {
              this.editType = '1'
            } else {
              this.editType = '2'
          }
            this.payTypeShow = true
            this.flagVal = '2'
            this.ifNewPost = '修改验工计价'
            this.postDataFun()
            return
        }
      },
      // 修改
      postDataFun() {
        var record = this.yanGongArr[0] // 当前点击的子项目信息
        var parentNode = this.newSeltVal() // 获取父项目信息
        if (record.isPush === '0' && record.orderState === '1') {
          // 订单状态有效且该条验工计价信息未推商合允许编辑  首付款（含安全生产费）不允许编辑
          this.formIfType = '1' // 保存时传的值
          this.dialogVisible = true
          // this.dialogEl('newDialogRef') // 外部打开弹框
          this.postOldCurrNum = this.yanGongArr[0].currentInspectionNum // 获取当前这条数据的本期验工数量
          this.postOldCurrMony = this.yanGongArr[0].currentInspectionMoney // 获取当前这条数据的本期验工金额
          this.form = {
            projectProGress: this.yanGongArr[0].projectProGress,
            payType: this.yanGongArr[0].payType,
            currentInspectionNum: this.yanGongArr[0].currentInspectionNum,
            currentInspectionMoney: this.yanGongArr[0].currentInspectionMoney,
            sumNum: parentNode[0].sumNum,
            sumMoney: parentNode[0].sumMoney
          }
          if (this.yanGongArr[0].projectProGress === '100') {
            this.currentInspectionMoneyShow = false
          } else {
            this.currentInspectionMoneyShow = true
          }
        } else {
          this.$message({
                  message: '仅支持对推送状态为"未推送"且订单状态为“有效”的验工计价结果发起修改操作',
                  type: 'warning'
            })
          return
        }
      },
      // 验工计价-综合查询-项目操作-删除
      delFun() {
        if (this.AllVerify() === '1' || this.AllVerify() === '2') { // 推送,冲销,修改,删除:全选&&未全选
            this.$message({
                message: '请选择一条未推送验工计价结果进行删除操作',
                type: 'warning'
            })
            return
        }

        this.yuGuDanArr = [] // 先清空
        this.yanGongArr = [] // 先清空
        this.filtrationSelectingData()

        if (this.yuGuDanArr.length > 1 || (this.yanGongArr.length > 1 && this.yuGuDanArr.length > 1)) {
            this.$message({
                message: '请选择一条未推送验工计价结果进行删除操作',
                type: 'warning'
            })
            return
        }

        if (this.yanGongArr.length > 1 || this.yuGuDanArr.length === 1) {
            this.$message({
                message: '请选择一条未推送验工计价结果进行删除操作',
                type: 'warning'
            })
            return
        }

        if (this.yanGongArr.length === 1 && this.yanGongArr[0].isPush === '1') { // 选中已推送的验工计价结果并点击【删除】按钮时
            this.$message({
                message: '仅支持对推送状态为“未推送”且订单状态为“有效”的验工计价结果发起删除操作',
                type: 'warning'
            })
            return
        }

        if (this.yanGongArr.length === 1) {
            this.delDtataFun()
            return
        }
      },
      async delDtataFunrepairOne(record, parentNode) {
        if (record.isPush === '0' && parentNode[0].orderState === '1' && this.delDtataFunrepairTwo(record) && record.orderState === '1') {
          // 订单状态有效且该条验工计价信息未推商合允许删除编辑  首付款（含安全生产费）不允许编辑
        } else {
          this.$message({
            dangerouslyUseHTMLString: true,
            message: '支持删除符合以下条件的验工计价信息:<br/><br/>(1)付款类型为进度款且订单状态为“有效”的验工结果且未推送商合，<br/><br/>(2)付款类型为首付款且当前金额小于0时且订单状态为“有效”且未推送商合',
            type: 'warning'
          })
          return Promise.reject()
        }
      },
      async delDtataFunrepairTwo(record) {
        return (record.payType === 'PROGRESSING' || (record.payType === 'FIRST' && Number(record.currentInspectionMoney) < 0))
      },
      async delDtataFunrepairThree(parentNode, diffNum, diffMoney, sumNum, currentInspectionNum, shNum) {
        if (this.newOldProject === '1') { // 老项目的时候onlybe1FLAG校验
          await this.delDtataFunrepairFour(parentNode, diffNum, diffMoney, sumNum, currentInspectionNum, shNum)
        } else {
          await this.delDtataFunrepairFive(parentNode, diffNum, diffMoney, sumNum, currentInspectionNum, shNum)
        }
      },
      async delDtataFunrepairFour(parentNode, diffNum, diffMoney, sumNum, currentInspectionNum, shNum) {
        if (parentNode[0].onlybe1FLAG === 'N' && diffNum < 0) {
            this.$message({
              message: '本订单的累计验工数量应大于等于0！',
              type: 'warning'
            })
            return Promise.reject()
          }
          if (parentNode[0].onlybe1FLAG === 'Y' && diffMoney < 0) {
            this.$message({
              message: '本订单的累计验工金额应大于等于0！',
              type: 'warning'
            })
            return Promise.reject()
          }
          if (parentNode[0].onlybe1FLAG === 'N' && this.farmatMoney(sumNum - currentInspectionNum) > shNum) {
            this.$message({
              message: '删除后当前预估单的累计验工数量超过了商合预占数，因此不能删除！',
              type: 'warning'
            })
            return Promise.reject()
          }
       },
      async delDtataFunrepairFive(parentNode, diffNum, diffMoney, sumNum, currentInspectionNum, shNum) {
        if (diffNum < 0) {
            this.$message({
              message: '本订单的累计验工数量应大于等于0！',
              type: 'warning'
            })
            return Promise.reject()
          }
          if (diffMoney < 0) {
            this.$message({
              message: '本订单的累计验工金额应大于等于0！',
              type: 'warning'
            })
            return Promise.reject()
          }
          if (this.farmatMoney(sumNum - currentInspectionNum) > shNum) {
            this.$message({
              message: '删除后当前预估单的累计验工数量超过了商合预占数，因此不能删除！',
              type: 'warning'
            })
            return Promise.reject()
          }
      },
      async delDtataFunrepairSix(sumMoney, currentInspectionMoney, shMoney) {
        if (this.farmatMoney(sumMoney - currentInspectionMoney) > shMoney || this.farmatMoney(sumMoney - currentInspectionMoney) < 0) {
                    this.$message({
                          message: '删除后当前预估单的累计验工金额超过了商合预占金额，因此不能删除！',
                          type: 'warning'
                    })
                    return Promise.reject()
                }
      },
      async delDtataFunrepairSeven(gCheckData, allSupplementNum) {
        let backdata = allSupplementNum
        if (gCheckData.data.supplementNum !== '') {
          backdata = gCheckData.data.supplementNum.SH_NUM_SUM // 在建工程损失补采数量
        }
        return backdata
       },
      async delDtataFunrepairEight(allServiceShNumSum, allServiceTServListAmount, minSumNum) {
        let backdata = minSumNum
        if (allServiceShNumSum > allServiceTServListAmount) { // 服务所有订单下商合预占数量的和 大于设计表服务数量
          backdata = allServiceTServListAmount
        } else {
          backdata = allServiceShNumSum
        }
        return backdata
      },
      async delDtataFunrepairNine(allServiceShNumSum, allServiceTServListAmount, allServiceTServListAdjAmount) {
        const datas = allServiceShNumSum < allServiceTServListAmount ? (allServiceShNumSum < allServiceTServListAdjAmount ? allServiceShNumSum : allServiceTServListAdjAmount) : (allServiceTServListAmount < allServiceTServListAdjAmount ? allServiceTServListAmount : allServiceTServListAdjAmount)
        return datas
      },
      async delDtataFunrepairTen(parentNode, allServiceSumNum, minSumNum, ifEngineeringVisa) {
        if (this.newOldProject === '1') { // 老项目的时候onlybe1FLAG校验
          await this.delDtataFunrepairEleve(parentNode, allServiceSumNum, minSumNum, ifEngineeringVisa)
        } else {
          await this.delDtataFunrepairTweleve(parentNode, allServiceSumNum, minSumNum, ifEngineeringVisa)
        }
      },
      async delDtataFunrepairEleve(parentNode, allServiceSumNum, minSumNum, ifEngineeringVisa) {
        if (parentNode[0].onlybe1FLAG === 'N' && allServiceSumNum > minSumNum && ifEngineeringVisa.data !== '1') {
            this.$message({
              message: '当前服务编码所有预估单累计验工数量应小于等于本服务所有预估单的累计商合预占数或设计清单数量！',
              type: 'warning'
            })
            return Promise.reject()
          }
      },
      async delDtataFunrepairTweleve(parentNode, allServiceSumNum, minSumNum, ifEngineeringVisa) {
        if (allServiceSumNum > minSumNum && ifEngineeringVisa.data !== '1') {
            this.$message({
              message: '当前服务编码所有预估单累计验工数量应小于等于本服务所有预估单的累计商合预占数或设计清单数量！',
              type: 'warning'
            })
            return Promise.reject()
          }
      },
      // 删除
    async  delDtataFun() {
        this.oldSumMoney = this.newSeltVal()[0].sumMoney // 获取父项目信息
        this.oldSumNum = this.newSeltVal()[0].sumNum // 获取父项目信息
        console.log(this.oldSumMoney, this.oldSumNum, 'this.oldSumMoneythis.oldSumNum')
        var record = this.yanGongArr[0] // 当前点击的子项目信息
        var parentNode = this.newSeltVal() // 获取父项目信息
        console.log(record.isPush, 'record.isPush')
        await this.delDtataFunrepairOne(record, parentNode)
        this.$confirm('确认删除该明细？', '删除提醒', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            cancelButtonClass: 'pms-zr-button',
            confirmButtonClass: 'pms-zr-button-primary',
            type: 'warning'
          }).then(async() => {
                const currentInspectionNum = Number(record.currentInspectionNum)
                const currentInspectionMoney = Number(record.currentInspectionMoney)
                const sumNum = Number(parentNode[0].sumNum) // 该订单累计验工数量
                const sumMoney = Number(parentNode[0].sumMoney) // 该订单累计验工金额
                const shNum = Number(parentNode[0].shNum) // 该订单累计验工数量
                const shMoney = Number(parentNode[0].shMoney) // 该订单累计验工金额
                const diffNum = Number(sumNum) - Number(currentInspectionNum)
                const diffMoney = Number(sumMoney) - Number(currentInspectionMoney)
                await this.delDtataFunrepairThree(parentNode, diffNum, diffMoney, sumNum, currentInspectionNum, shNum)
                await this.delDtataFunrepairSix(sumMoney, currentInspectionMoney, shMoney)

                var flag = false
                /*       站址下服务所有订单的【本次验工计价数量】（包含历史）之和<=站址下服务所有订单的【交易下单采购数量】之和、站址的服务【设计数量】、在途站址的服务【设计变更数量】三者的最小值，且>=0； start
                */
                var serviceCode = parentNode[0].serviceCode
                var subPrjId = record.subPrjId
                var prjId = record.prjId
                var vId = record.vid

                // var allServiceSumMoney = 0 // 服务所有订单下累计验工金额
                var allServiceSumNum = 0 // 服务所有订单下累计验工数量
                // var allServiceShMoneySum = 0 // 服务所有订单下商合预占金额的和
                var allServiceShNumSum = 0 // 服务所有订单下商合预占数量的和
                var allServiceTServListAmount = 0 // 设计表服务数量
                // var allServiceTServListEquipSum = 0 // 设计表服务及金额
                var allServiceTServListAdjAmount = 0 // 设计变更表服务数量
                // var allServiceTServListAdjEquipSum = 0 // 设计变更表服务及金额
                var allSupplementNum = 0 // 在建工程损失补采数量
                // var minSumMoney = 0 //1.0 声明未调用
                var minSumNum = 0

                const obj = {
                  serviceCode: serviceCode,
                  subPrjId: subPrjId,
                  prjId: prjId,
                  vId: vId
                }

            const ifEngineeringVisa = await ifEngineeringVisaNew({ serviceCode: serviceCode })
            console.log(ifEngineeringVisa.data, 'ifEngineeringVisa.data')
            const gCheckData = await getCheckInsVaDataNew(obj)
            if (gCheckData.code === '200') {
              // allServiceSumMoney = this.farmatMoney(Number(gCheckData.data.CURRENT_INSPECTION_MONEY_SUM))
              allServiceSumNum = this.farmatNum(Number(gCheckData.data.currentInspectionSum.CURRENT_INSPECTION_NUM_SUM)) // 所有订单累计数量(不包括当前)
              // allServiceShMoneySum = gCheckData.data.shSum.SH_MONEY_SUM
              allServiceShNumSum = gCheckData.data.shSum.SH_NUM_SUM
              allSupplementNum = await this.delDtataFunrepairSeven(gCheckData, allSupplementNum)

              // allServiceTServListEquipSum = gCheckData.data.serListSum.SJ_MONEY
              allServiceTServListAmount = gCheckData.data.serListSum.SJ_AMOUNT

              allServiceTServListAmount = allServiceTServListAmount + allSupplementNum
              if (gCheckData.data.serListAdjSum.SJ_ADJ_AMOUNT || gCheckData.data.serListAdjSum.SJ_ADJ_MONEY) { // 设计变更表中有数据已发生设计变更  在商合、设计、设计变更 金额中取最小值
                // allServiceTServListAdjEquipSum = gCheckData.data.serListAdjSum.SJ_ADJ_MONEY
                allServiceTServListAdjAmount = gCheckData.data.serListAdjSum.SJ_ADJ_AMOUNT

                allServiceTServListAdjAmount = allServiceTServListAdjAmount + allSupplementNum
                // 商合、设计、设计变更金额取最小值
                minSumNum = await this.delDtataFunrepairNine(allServiceShNumSum, allServiceTServListAmount, allServiceTServListAdjAmount)
              } else {
                minSumNum = await this.delDtataFunrepairEight(allServiceShNumSum, allServiceTServListAmount, minSumNum)
              }
              await this.delDtataFunrepairTen(parentNode, allServiceSumNum, minSumNum, ifEngineeringVisa)
            }

            const data = {
              onlyBe1Flag: parentNode[0].onlybe1FLAG, currentInspectionNum: currentInspectionNum,
              currentInspectionMoney: currentInspectionMoney,
              serviceCode: serviceCode, prjId: prjId, subPrjId: subPrjId,
              pId: record.pid, vId: vId, flag: '3', oldSumMoney: this.oldSumMoney, oldSumNum: this.oldSumNum
            }
            const updateInsVaDetails = await updateInsVaDetailsNew(data)
            if (updateInsVaDetails.code === '200') {
              this.listData()
              this.$message({
                message: '删除成功',
                type: 'success'
              })
            }
          }).catch(() => {
            console.log('[]')
          })
      },
      // 批量新增关闭
      closeTwo() {
        this.fomrDialogVisible = false // 批量新增验工计价展示
        // this.dialogClosed() // 外部关闭弹框
        this.detailFormData = []
      },
      handleColseTwo() {
        this.closeTwo()
      },
      // 关闭
      close() {
        this.form = {
            projectProGress: '', // 项目进度
            payType: 'PROGRESSING', // 付款类型
            currentInspectionNum: '', // 本期验工数量
            currentInspectionMoney: '', // 本期验工计价金额
            sumNum: '', // 累计验工数量
            sumMoney: '' // 累计验工计价金额
        }
        this.xiugaiValu = '' // 清空值 ！勿动
        this.dialogVisible = false
        // this.dialogClosed() // 外部关闭弹框
      },
      handleColse() {
        this.close()
      },
      // 封装公共的获取父项目
      newSeltVal() {
        var selectionVal = [] // 获取父项目信息
        this.detailData.map(v => {
          if (this.yanGongArr[0].pid === v.vid) {
            selectionVal.push(v)
          }
        })
        return selectionVal
      },
      async repairNewSaveOne() {
      if (this.formIfType === '1') {
        // 判断点击的是不是修改
        this.oldSumMoney = this.newSeltVal()[0].sumMoney // 获取父项目信息
        this.oldSumNum = this.newSeltVal()[0].sumNum // 获取父项目信息
      } else {
        this.oldSumMoney = this.yuGuDanArr[0].sumMoney
        this.oldSumNum = this.yuGuDanArr[0].sumNum
      }
    },
    async repairNewSaveTwo(epcServiceType, currentInspectionNum) {
      const r = /^(?!0\d)\d*$/
      if (epcServiceType === '1' && !r.test(Math.abs(currentInspectionNum))) { // 保存按钮启用
        this.$message({
          message: '该服务编码属于微站EPC总包服务编码,验工计价数量只能填写整数，请修改！',
          type: 'warning'
        })
        return Promise.reject()
      }
      if (epcServiceType === '2' && !r.test(Math.abs(currentInspectionNum))) {
        this.$message({
          message: '该服务编码属于微站施工总包服务编码,验工计价数量只能填写整数，请修改！',
          type: 'warning'
        })
        return Promise.reject()
      }
      if (epcServiceType === '3' && !r.test(Math.abs(currentInspectionNum))) {
        this.$message({
          message: '该服务编码属于新疆机房总承包服务编码,验工计价数量只能填写整数，请修改！',
          type: 'warning'
        })
        return Promise.reject()
      }
    },
    async repairNewSaveThree(onlyBe1Flag, currentInspectionMoney, currentInspectionNum, sumMoney, shMoney, projectProgress, sumNum, shNum) {
      if (this.newOldProject === '1') { // 老项目的时候onlybe1FLAG校验
        await this.repairNewSaveThreeFirst(onlyBe1Flag, currentInspectionMoney, currentInspectionNum)
        await this.repairNewSaveThreeSecond(onlyBe1Flag, currentInspectionMoney, currentInspectionNum)
        await this.repairNewSaveThreeThird(onlyBe1Flag, sumMoney, shMoney, projectProgress, sumNum, shNum)
        await this.repairNewSaveThreeFourth(onlyBe1Flag, sumMoney, shMoney, sumNum, shNum)
        // 保存新增验工计价历史校验：
        await this.repairNewSaveThreeFifth(onlyBe1Flag, sumNum, sumMoney)
      } else {
        await this.repairNewSaveThreeSixth(currentInspectionMoney, currentInspectionNum)
        await this.repairNewSaveThreeSeventh(currentInspectionMoney, currentInspectionNum)
        await this.repairNewSaveThreeEighth(sumMoney, shMoney, projectProgress, sumNum, shNum)
        await this.repairNewSaveThreeNineth(sumMoney, shMoney, sumNum, shNum)
        // 保存新增验工计价历史校验
        await this.repairNewSaveThreeTenth(sumNum, sumMoney)
      }
    },
    async repairNewSaveThreeFirst(onlyBe1Flag, currentInspectionMoney, currentInspectionNum) {
      if (this.editType === '1') {
        if (onlyBe1Flag === 'N' && (currentInspectionMoney < 0 || currentInspectionNum < 0)) {
          this.$message({
            message: '当前为新增验工计价，请填写正数验工计价！',
            type: 'warning'
          })
          return Promise.reject()
        }
        if (onlyBe1Flag === 'Y' && currentInspectionMoney < 0) {
          this.$message({
            message: '当前为新增验工计价，请填写正数验工计价！',
            type: 'warning'
          })
          return Promise.reject()
        }
      }
    },
    async repairNewSaveThreeSecond(onlyBe1Flag, currentInspectionMoney, currentInspectionNum) {
      if (this.editType === '2') {
        await this.repairNewSaveThreeSecondOne(onlyBe1Flag, currentInspectionMoney, currentInspectionNum)
        if (onlyBe1Flag === 'Y' && currentInspectionMoney >= 0) {
          this.$message({
            message: '当前为冲销验工计价，请填写负数且不能超出本次冲销付款类型下已推送商合的累计验工计价!',
            type: 'warning'
          })
          return Promise.reject()
        }
      }
    },
    async repairNewSaveThreeSecondOne(onlyBe1Flag, currentInspectionMoney, currentInspectionNum) {
      if (onlyBe1Flag === 'N' && (currentInspectionMoney >= 0 || currentInspectionNum >= 0) && this.firstNum !== '0') {
          this.$message({
            message: '当前为冲销验工计价，请填写负数且不能超出本次冲销付款类型下已推送商合的累计验工计价!',
            type: 'warning'
          })
          return Promise.reject()
        }
    },
    async repairNewSaveThreeThird(onlyBe1Flag, sumMoney, shMoney, projectProgress, sumNum, shNum) {
      if (this.editType === '1' && onlyBe1Flag === 'Y' && Number(sumMoney) === Number(shMoney) && projectProgress !== '100') {
        this.$message({
          message: Number(sumNum) > Number(shNum) ? '当前累计验工计价数量' + sumNum + '大于商合预占数量' + shNum + '，请调整验工计价数量!' : '当前预估单累计验工数量等于商合预占数量，需要将项目进度填为100！',
          type: 'warning'
        })
        return Promise.reject()
      }
    },
    async repairNewSaveThreeFourth(onlyBe1Flag, sumMoney, shMoney, sumNum, shNum) {
      if (this.editType === '1' && onlyBe1Flag === 'N' && Number(sumMoney) === Number(shMoney) && Number(sumNum) > Number(shNum)) {
          this.$message({
            message: '当前累计验工计价数量' + sumNum + '大于商合预占数量' + shNum + '，请调整验工计价数量！',
            type: 'warning'
          })
          return Promise.reject()
        }
    },
    async repairNewSaveThreeFifth(onlyBe1Flag, sumNum, sumMoney) {
      if (onlyBe1Flag === 'N' && Number(sumNum) === 0 && Number(sumMoney) !== 0) {
          this.$message({
            message: '当前预估单累计验工数量为0，累计预占金额应调整为0，请修改！',
            type: 'warning'
          })
          return Promise.reject()
        }
    },
    async repairNewSaveThreeSixth(currentInspectionMoney, currentInspectionNum) {
      if (this.editType === '1') {
          if (currentInspectionMoney < 0 || currentInspectionNum < 0) {
            this.$message({
              message: '当前为新增验工计价，请填写正数验工计价！',
              type: 'warning'
            })
            return Promise.reject()
          }
           if (currentInspectionMoney < 0) {
            this.$message({
              message: '当前为新增验工计价，请填写正数验工计价！',
              type: 'warning'
            })
            return Promise.reject()
          }
        }
    },
    async repairNewSaveThreeSeventh(currentInspectionMoney, currentInspectionNum) {
      if (this.editType === '2') {
          console.log(11111111111111, currentInspectionMoney, currentInspectionNum)
          if ((currentInspectionMoney >= 0 || currentInspectionNum >= 0) && this.firstNum !== '0') {
            this.$message({
              message: '当前为冲销验工计价，请填写负数且不能超出本次冲销付款类型下已推送商合的累计验工计价!',
              type: 'warning'
            })
            return Promise.reject()
          }
           if (currentInspectionMoney >= 0) {
            this.$message({
              message: '当前为冲销验工计价，请填写负数且不能超出本次冲销付款类型下已推送商合的累计验工计价!',
              type: 'warning'
            })
            return Promise.reject()
          }
        }
    },
    async repairNewSaveThreeEighth(sumMoney, shMoney, projectProgress, sumNum, shNum) {
      if (this.editType === '1' && Number(sumMoney) === Number(shMoney) && projectProgress !== '100') {
          this.$message({
            message: Number(sumNum) > Number(shNum) ? '当前累计验工计价数量' + sumNum + '大于商合预占数量' + shNum + '，请调整验工计价数量!' : '当前预估单累计验工数量等于商合预占数量，需要将项目进度填为100！',
            type: 'warning'
          })
          return Promise.reject()
        }
    },
    async repairNewSaveThreeNineth(sumMoney, shMoney, sumNum, shNum) {
      if (this.editType === '1' && Number(sumMoney) === Number(shMoney) && Number(sumNum) > Number(shNum)) {
          this.$message({
            message: '当前累计验工计价数量' + sumNum + '大于商合预占数量' + shNum + '，请调整验工计价数量！',
            type: 'warning'
          })
          return Promise.reject()
        }
    },
    async repairNewSaveThreeTenth(sumNum, sumMoney) {
      if (Number(sumNum) === 0 && Number(sumMoney) !== 0) {
          this.$message({
            message: '当前预估单累计验工数量为0，累计预占金额应调整为0，请修改！',
            type: 'warning'
          })
          return Promise.reject()
        }
    },
    async repairNewSaveFour(onlyBe1Flag, sumNum, shNum, projectProgress, currentInspectionMoney, price, currentInspectionNum, shMoney) {
      if (this.newOldProject === '1') { // 老项目的时候onlybe1FLAG校验
        await this.repairNewSaveFourFirst(onlyBe1Flag, sumNum, shNum, projectProgress)
        await this.repairNewSaveFourSecond(onlyBe1Flag, sumNum, shNum, currentInspectionNum, price, currentInspectionMoney, shMoney)
      } else {
        await this.repairNewSaveFourThird(sumNum, shNum, projectProgress)
        await this.repairNewSaveFourFourth(currentInspectionNum, price, currentInspectionMoney, sumNum, shNum)
        await this.repairNewSaveFourFiveth(currentInspectionMoney, shMoney)
      }
    },
    async repairNewSaveFourFirst(onlyBe1Flag, sumNum, shNum, projectProgress) {
      if (this.editType === '1' && onlyBe1Flag === 'N' && Number(sumNum) === Number(shNum) && projectProgress !== '100') {
          this.$message({
            message: '当前预估单累计验工数量等于商合预占数量，需要将项目进度填为100！',
            type: 'warning'
          })
          return Promise.reject()
        }
    },
    async repairNewSaveFourSecond(onlyBe1Flag, sumNum, shNum, currentInspectionNum, price, currentInspectionMoney, shMoney) {
      if (onlyBe1Flag === 'N') {
          var Money = Number(currentInspectionNum) * Number(price)
          Money = this.farmatMoney(Money)
          if (this.editType === '1' && await this.repairNewSaveFourSecondOne(Money, sumNum, shNum, currentInspectionMoney)) {
            this.$message({
              message: '调整区间为系统自动计算金额上下浮动' + this.floataMountMax + '元',
              type: 'warning'
            })
            return Promise.reject()
          }
          if (Number(currentInspectionMoney) > Number(shMoney)) {
            this.$message({
              message: '本期验工金额应小于商合预占金额',
              type: 'warning'
            })
            return Promise.reject()
          }
        }
    },
    async repairNewSaveFourSecondOne(Money, sumNum, shNum, currentInspectionMoney) {
      return (((Money - this.floataMountMax) > currentInspectionMoney) || ((Money + this.floataMountMax) < currentInspectionMoney)) && Number(sumNum) !== Number(shNum) && sumNum !== '0'
    },
    async repairNewSaveFourThird(sumNum, shNum, projectProgress) {
      if (this.editType === '1' && Number(sumNum) === Number(shNum) && projectProgress !== '100') {
          this.$message({
            message: '当前预估单累计验工数量等于商合预占数量，需要将项目进度填为100！',
            type: 'warning'
          })
          return Promise.reject()
        }
    },
    async repairNewSaveFourFourth(currentInspectionNum, price, currentInspectionMoney, sumNum, shNum) {
        var MoneyVal = Number(currentInspectionNum) * Number(price)
        MoneyVal = this.farmatMoney(MoneyVal)
        if (this.editType === '1' && await this.repairNewSaveFourFourthOne(MoneyVal, currentInspectionMoney, sumNum, shNum)) {
          this.$message({
            message: '调整区间为系统自动计算金额上下浮动' + this.floataMountMax + '元',
            type: 'warning'
          })
          return Promise.reject()
        }
    },
   async repairNewSaveFourFourthOne(MoneyVal, currentInspectionMoney, sumNum, shNum) {
    return (((MoneyVal - this.floataMountMax) > currentInspectionMoney) || ((MoneyVal + this.floataMountMax) < currentInspectionMoney)) && Number(sumNum) !== Number(shNum) && sumNum !== '0'
   },
    async repairNewSaveFourFiveth(currentInspectionMoney, shMoney) {
      if (Number(currentInspectionMoney) > Number(shMoney)) {
          this.$message({
            message: '本期验工金额应小于商合预占金额',
            type: 'warning'
          })
          return Promise.reject()
        }
    },
    async repairNewSaveFive(projectProgress, currentInspectionMoney, currentInspectionNum) {
      if (this.editType === '1') {
        if (projectProgress === 'PROGRESSING' && Number(currentInspectionMoney) === 0 || Number(currentInspectionNum) === 0) {
          this.$message({
            message: '填写的本期验工数量或本期验工金额请大于0',
            type: 'warning'
          })
          return Promise.reject()
        }
        if (projectProgress === 'PROGRESSING' && Number(currentInspectionMoney) === 0) {
          this.$message({
            message: '填写的本期验工金额请大于0',
            type: 'warning'
          })
          return Promise.reject()
        }
        // 进度款：本期验工数量与本期验工金额为0时，均不能保存，首付款：本期验工金额为0时无法保存
      }
    },
    async repairNewSaveSix(onlyBe1Flag, sumNum, shNum) {
      if (this.newOldProject === '1') { // 老项目的时候onlybe1FLAG校验
        if (onlyBe1Flag === 'N' && Number(sumNum) > Number(shNum)) {
          this.$message({
            message: '当前预估单的累计验工数量应小于等于商合预占数!',
            type: 'warning'
          })
          return Promise.reject()
        }
      } else {
        if (Number(sumNum) > Number(shNum)) {
          this.$message({
            message: '当前预估单的累计验工数量应小于等于商合预占数!',
            type: 'warning'
          })
          return Promise.reject()
        }
      }
    },
    async repairNewSaveSeven(sumNum, sumMoney, shMoney) {
      if (sumNum < 0) {
        this.$message({
          message: '当前预估单的累计验工数量应大于等于0！',
          type: 'warning'
        })
        return Promise.reject()
      }

      if (Number(sumMoney) > Number(shMoney) || Number(sumMoney) < 0) {
        this.$message({
          message: '当前预估单的累计验工金额应小于等于商合预占及金额且大于等于0！',
          type: 'warning'
        })
        return Promise.reject()
      }
     },
    async repairNewSaveEight(gCheckData, allServiceSumNum, currentInspectionNum) {
      let backdata = allServiceSumNum
      if (this.flagVal === '2') { // 保存的是修改后的数据时
        backdata = this.farmatNum(Number(gCheckData.data.currentInspectionSum.CURRENT_INSPECTION_NUM_SUM) + Number(currentInspectionNum) - Number(this.postOldCurrNum)) // 所有订单累计数量+当前所填本期验工数量-修改前的本期验工数量
      } else {
        backdata = this.farmatNum(Number(gCheckData.data.currentInspectionSum.CURRENT_INSPECTION_NUM_SUM) + Number(currentInspectionNum)) // 所有订单累计数量+当前所填本期验工数量
        console.log(backdata, 'allServiceSumNum--allServiceSumNum')
      }
      return backdata
    },
    async repairNewSaveNine(gCheckData, allSupplementNum) {
      let backdata = allSupplementNum
      if (gCheckData.data.supplementNum.SUPPLEMENT_NUM) {
        backdata = gCheckData.data.supplementNum.SUPPLEMENT_NUM // 在建工程损失补采数量
      }
      return backdata
     },
    async repairNewSaveTen(gCheckData, allServiceTServListAmount, allSupplementNum) {
      let backdata = allServiceTServListAmount
      if (gCheckData.data.serListSum.SJ_MONEY || gCheckData.data.serListSum.SJ_AMOUNT) {
        backdata = gCheckData.data.serListSum.SJ_AMOUNT
        if (backdata === null) {
          console.log('服务设计表中无该条服务数据')
        }
        // 设计表建设数量+在建工程损失数量
        backdata = gCheckData.data.serListSum.SJ_AMOUNT + allSupplementNum
      }
      return backdata
    },
    async repairNewSaveTweleve(gCheckData, allServiceTServListAdjAmount, allSupplementNum, allServiceShNumSum, allServiceTServListAmount, minSumNum) {
      let backdata1 = allServiceTServListAdjAmount
      let backdata2 = minSumNum
      if (gCheckData.data.serListAdjSum.SJ_ADJ_AMOUNT || gCheckData.data.serListAdjSum.SJ_ADJ_MONEY) { // 设计变更表中有数据已发生设计变更  在商合、设计、设计变更 金额中取最小值
        // 设计表服务预算合价+在建工程损失金额
        backdata1 = gCheckData.data.serListAdjSum.SJ_ADJ_AMOUNT
        if (backdata1 === null) {
          console.log('服务设计表中无该条服务数据')
        }
        // 设计表服务建设数量+在建工程损失数量
        backdata1 = gCheckData.data.serListAdjSum.SJ_ADJ_AMOUNT + allSupplementNum
        // 商合、设计+补采、设计变更+补采取最小值
        backdata2 = await this.repairNewSaveTweleveOne(backdata1, allServiceShNumSum, allServiceTServListAmount)
      } else {
        backdata2 = await this.repairNewSaveTweleveTwo(allServiceShNumSum, allServiceTServListAmount, backdata2)
      }
      return {
        backdata1,
        backdata2
      }
    },
    async repairNewSaveTweleveOne(backdata1, allServiceShNumSum, allServiceTServListAmount) {
      return allServiceShNumSum < allServiceTServListAmount ? (allServiceShNumSum < backdata1 ? allServiceShNumSum : backdata1) : (allServiceTServListAmount < backdata1 ? allServiceTServListAmount : backdata1)
    },
    async repairNewSaveTweleveTwo(allServiceShNumSum, allServiceTServListAmount, backdata2) {
      let result = backdata2
      if (allServiceShNumSum > allServiceTServListAmount) { // 服务所有订单下商合预占数量的和 大于设计表服务数量
        result = allServiceTServListAmount
        } else {
          result = allServiceShNumSum
        }
        return result
    },
    async repairNewSaveThirteen(bijiaoVal, projectProgress) {
      let backdata = bijiaoVal
      if (projectProgress === '100') {
        backdata = this.form.sumNum
     }
     return backdata
    },
    async repairNewSaveFourteen(bijiaoVal, desGrossWight, desGrossWightNumb, serviceCode, currentInspectionMoney, taxrate, pId, prjId, subPrjId, onlyBe1Flag, siteId, currentInspectionNum, sumMoney, sumNum, projectProgress, orderDetailId, purchaseMode, vId) {
      if (bijiaoVal !== '' && desGrossWight > bijiaoVal) {
        this.$confirm('以下服务的验工计价总量不足设计量的' + desGrossWightNumb + '%，请确定是否正常。' + '服务编码:' + serviceCode + '如需返回修改，请点击‘取消’！ 如确定无误，请点击‘确定’进行下一步！', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          cancelButtonClass: 'pms-zr-button',
          confirmButtonClass: 'pms-zr-button-primary',
          type: 'warning'
        }).then(async() => {
          let inspectionTax = Number(currentInspectionMoney) * Number(taxrate) // 验工计价税额 = 本期验工金额*税率
          inspectionTax = this.farmatMoney(inspectionTax)
          const inspectionTaxAmount = this.farmatMoney(Number(currentInspectionMoney) + Number(inspectionTax)) // 含税验工计价总金额 = 本期验工金额 + 验工计价税额
          if (this.flagVal === '1') {
            const dataVal = {
              pId: pId, prjId: prjId, subPrjId: subPrjId, onlyBe1Flag: onlyBe1Flag, siteId: siteId, serviceCode: serviceCode,
              currentInspectionNum: currentInspectionNum, currentInspectionMoney: currentInspectionMoney, sumMoney: sumMoney,
              sumNum: sumNum, projectProgress: projectProgress, inspectionTax: inspectionTax, inspectionTaxAmount: inspectionTaxAmount,
              orderDetailId: orderDetailId, purchaseMode: purchaseMode, payType: this.form.payType, flag: '1', oldSumMoney: this.oldSumMoney, oldSumNum: this.oldSumNum
            }
            this.initSaveData(dataVal)
          }
          if (this.flagVal === '2') {
            const dataVals = {
              vId: vId, pId: pId, currentInspectionNum: currentInspectionNum, currentInspectionMoney: currentInspectionMoney,
              projectProgress: projectProgress, onlyBe1Flag: onlyBe1Flag, sumNum: sumNum, sumMoney: sumMoney,
              serviceCode: serviceCode, prjId: prjId, subPrjId: subPrjId, inspectionTax: inspectionTax, inspectionTaxAmount: inspectionTaxAmount, flag: '2', oldSumMoney: this.oldSumMoney, oldSumNum: this.oldSumNum
            }
            this.initSaveData(dataVals)
          }
        }).catch(() => {
          console.log('cancel')
        })
        return Promise.reject()
      }
     },
    async repairNewSaveFiveteen(onlyBe1Flag, allServiceSumNum, minSumNum, ifEngineeringVisa, gCheckData, sumNum, serviceCode) {
      if (this.newOldProject === '1') { // 老项目的时候onlybe1FLAG校验
        console.log('editType', this.editType, 'flagVal', this.flagVal)
        await this.repairNewSaveSixteen(onlyBe1Flag, allServiceSumNum, minSumNum, ifEngineeringVisa, gCheckData, sumNum, serviceCode)
      } else {
        console.log('editType', this.editType, 'flagVal', this.flagVal)
        await this.repairNewSaveSeventeen(allServiceSumNum, minSumNum, ifEngineeringVisa, gCheckData, sumNum, serviceCode)
      }
     },
    async repairNewSaveSixteen(onlyBe1Flag, allServiceSumNum, minSumNum, ifEngineeringVisa, gCheckData, sumNum, serviceCode) {
      await this.repairNewSaveSixteenOne(onlyBe1Flag, allServiceSumNum, minSumNum, ifEngineeringVisa, gCheckData, sumNum, serviceCode)
        if (onlyBe1Flag === 'N' && allServiceSumNum < 0) {
          this.$message({
            message: '本服务所有预估单的累计验工数量应大于等于0！',
            type: 'warning'
          })
          return Promise.reject()
        }
     },
      async repairNewSaveSixteenOne(onlyBe1Flag, allServiceSumNum, minSumNum, ifEngineeringVisa, gCheckData, sumNum, serviceCode) {
        if (await this.repairNewSaveSixteenOne_first(onlyBe1Flag, allServiceSumNum, minSumNum, ifEngineeringVisa, gCheckData, sumNum, serviceCode) && !(this.editType === '2' && this.flagVal === '1')) {
          const sjSum = gCheckData.data.serListAdjSum.SJ_ADJ_AMOUNT ? gCheckData.data.serListAdjSum.SJ_ADJ_AMOUNT : gCheckData.data.serListSum.SJ_AMOUNT
          this.$message({
            message: gCheckData.data.serListSum.SJ_AMOUNT ? '当前累计验工计价数量（' + sumNum + '）大于设计数量（' + sjSum + '），请调整验工计价数量!' : '以下服务已从设计清单中移除，请将验工计价冲销为0或通过设计变更增加相应服务【服务编码】【' + serviceCode + '】!',
            type: 'warning'
          })
          return Promise.reject()
        }
      },
      async repairNewSaveSixteenOne_first(onlyBe1Flag, allServiceSumNum, minSumNum, ifEngineeringVisa, gCheckData, sumNum, serviceCode) {
        return onlyBe1Flag === 'N' && allServiceSumNum > minSumNum && ifEngineeringVisa.data !== '1'
      },
    async repairNewSaveSeventeen(allServiceSumNum, minSumNum, ifEngineeringVisa, gCheckData, sumNum, serviceCode) {
      await this.repairNewSaveSeventeenOne(allServiceSumNum, minSumNum, ifEngineeringVisa, gCheckData, sumNum, serviceCode)
        if (allServiceSumNum < 0) {
          this.$message({
            message: '本服务所有预估单的累计验工数量应大于等于0！',
            type: 'warning'
          })
          return Promise.reject()
        }
    },
    async repairNewSaveSeventeenOne(allServiceSumNum, minSumNum, ifEngineeringVisa, gCheckData, sumNum, serviceCode) {
      if (allServiceSumNum > minSumNum && ifEngineeringVisa.data !== '1' && !(this.editType === '2' && this.flagVal === '1')) {
          const sjSum = gCheckData.data.serListAdjSum.SJ_ADJ_AMOUNT ? gCheckData.data.serListAdjSum.SJ_ADJ_AMOUNT : gCheckData.data.serListSum.SJ_AMOUNT
          this.$message({
            message: gCheckData.data.serListSum.SJ_AMOUNT ? '当前累计验工计价数量（' + sumNum + '）大于设计数量（' + sjSum + '），请调整验工计价数量!' : '以下服务已从设计清单中移除，请将验工计价冲销为0或通过设计变更增加相应服务【服务编码】【' + serviceCode + '】!',
            type: 'warning'
          })
          return Promise.reject()
        }
    },
    async repairNewSaveEightteen(currentInspectionNum, currentInspectionMoney, pId, prjId, subPrjId, serviceCode, payType, onlyBe1Flag, shNum, shMoney) {
      if (this.editType === '2') {
        var currentInspectionNumPandDuan = ''
        var currentInspectionMoneyPandDuan = ''
        var num = ''
        var money = ''
        const { currentInspectionNumPandDuandata, currentInspectionMoneyPandDuandata } = await this.repairNewSaveTwenty(currentInspectionNumPandDuan, currentInspectionMoneyPandDuan, currentInspectionNum, currentInspectionMoney)
        currentInspectionNumPandDuan = currentInspectionNumPandDuandata
        currentInspectionMoneyPandDuan = currentInspectionMoneyPandDuandata
        console.log(currentInspectionNumPandDuan, currentInspectionMoneyPandDuan, 'PandDuan')
        const obj = { pId: pId, prjId: prjId, subPrjId: subPrjId, serviceCode: serviceCode, payType: payType }
        const gtCheckIsPushNum = await getCheckIsPushNumNew(obj)
        if (gtCheckIsPushNum.code === '200') {
          if (gtCheckIsPushNum.data !== null) {
              const { numdata, moneydata } = await this.repairNewSaveNineteen(payType, gtCheckIsPushNum, shNum, shMoney, num, money)
              num = numdata
              money = moneydata
              await this.repairNewSaveTwentyOne(onlyBe1Flag, currentInspectionNumPandDuan, currentInspectionMoneyPandDuan, num, money)
          } else {
            this.$message({
              message: '“付款类型”需与验工计价列表中，已推送商合的验工计价结果一致，如列表中仅存在首付款，则无法冲销进度款', // 原:校验已推送数量失败！
              type: 'warning'
            })
            return Promise.reject()
          }
        }
      }
    },
    async repairNewSaveNineteen(payType, gtCheckIsPushNum, shNum, shMoney, num, money) {
      let numdata = num
      let moneydata = money
      if (this.xiugaiValu === '1' && payType === 'PROGRESSING') { // 判断如果点击修改的冲销 比较的值用商合返回的
        numdata = shNum
        moneydata = shMoney
      } else { // 判断如果点击的冲销 比较的值用接口返回的
        numdata = gtCheckIsPushNum.data.CURRENT_INSPECTION_NUM_SUM
        moneydata = gtCheckIsPushNum.data.CURRENT_INSPECTION_MONEY_SUM
      }
      return {
        numdata,
        moneydata
      }
    },
    async repairNewSaveTwenty(currentInspectionNumPandDuan, currentInspectionMoneyPandDuan, currentInspectionNum, currentInspectionMoney) {
      let currentInspectionNumPandDuandata = currentInspectionNumPandDuan
      let currentInspectionMoneyPandDuandata = currentInspectionMoneyPandDuan
      if (this.xiugaiValu === '1') { // 判断如果点击修改的冲销 重新赋值
        currentInspectionNumPandDuandata = Number(currentInspectionNum) - Number(this.postOldCurrNum)
        currentInspectionMoneyPandDuandata = Number(currentInspectionMoney) - Number(this.postOldCurrMony)
        } else {
          currentInspectionNumPandDuandata = currentInspectionNum
          currentInspectionMoneyPandDuandata = currentInspectionMoney
        }
        return {
          currentInspectionNumPandDuandata,
          currentInspectionMoneyPandDuandata
        }
    },
    async repairNewSaveTwentyOne(onlyBe1Flag, currentInspectionNumPandDuan, currentInspectionMoneyPandDuan, num, money) {
      if (this.newOldProject === '1') { // 老项目的时候onlybe1FLAG校验
       await this.repairNewSaveTwentyTwo(onlyBe1Flag, currentInspectionNumPandDuan, currentInspectionMoneyPandDuan, num, money)
      } else {
        await this.repairNewSaveTwentyThree(currentInspectionNumPandDuan, currentInspectionMoneyPandDuan, num, money)
      }
     },
    async repairNewSaveTwentyTwo(onlyBe1Flag, currentInspectionNumPandDuan, currentInspectionMoneyPandDuan, num, money) {
      if (onlyBe1Flag === 'N' && (Math.abs(currentInspectionNumPandDuan) > num || Math.abs(currentInspectionMoneyPandDuan) > money)) {
          this.$message({
            message: '当前验工计价不能超出本次冲销付款类型下已推送商合的累计验工计价！',
            type: 'warning'
          })
          return Promise.reject()
        }
        if (onlyBe1Flag === 'Y' && Math.abs(currentInspectionMoneyPandDuan) > money) {
          this.$message({
            message: '当前验工计价不能超出本次冲销付款类型下已推送商合的累计验工计价！',
            type: 'warning'
          })
          return Promise.reject()
        }
    },
    async repairNewSaveTwentyThree(currentInspectionNumPandDuan, currentInspectionMoneyPandDuan, num, money) {
      if (Math.abs(currentInspectionNumPandDuan) > num || Math.abs(currentInspectionMoneyPandDuan) > money) {
          this.$message({
            message: '当前验工计价不能超出本次冲销付款类型下已推送商合的累计验工计价！',
            type: 'warning'
          })
          return Promise.reject()
        }
        if (Math.abs(currentInspectionMoneyPandDuan) > money) {
          this.$message({
            message: '当前验工计价不能超出本次冲销付款类型下已推送商合的累计验工计价！',
            type: 'warning'
          })
          return Promise.reject()
        }
    },
    async repairNewSaveTwentyFour(onlyBe1Flag, sumNum, shNum, sumMoney, shMoney) {
      if (this.newOldProject === '1') { // 老项目的时候onlybe1FLAG校验
        await this.repairNewSaveTwentyFourOne(onlyBe1Flag, sumNum, shNum, sumMoney, shMoney)
      } else {
        if (Number(sumNum) === Number(shNum) && Number(sumMoney) !== Number(shMoney)) {
          this.$message({
            message: '当前预估单累计验工数量等于商合预占数量,累计验工金额应等于预占金额，请修改！',
            type: 'warning'
          })
          return Promise.reject()
        }
      }
    },
   async repairNewSaveTwentyFourOne(onlyBe1Flag, sumNum, shNum, sumMoney, shMoney) {
    if (this.editType === '1' && onlyBe1Flag === 'N' && Number(sumNum) === Number(shNum) && Number(sumMoney) !== Number(shMoney)) {
          this.$message({
            message: '当前预估单累计验工数量等于商合预占数量,累计验工金额应等于预占金额，请修改！',
            type: 'warning'
          })
          return Promise.reject()
        }
   },
    async repairNewSaveTwentyFive(vId, pId, prjId, subPrjId, onlyBe1Flag, siteId, serviceCode, currentInspectionNum, currentInspectionMoney, sumMoney, sumNum, projectProgress, inspectionTax, inspectionTaxAmount, orderDetailId, purchaseMode) {
      let _backdata = {}
      if (this.flagVal === '1') {
        _backdata = {
          pId: pId, prjId: prjId, subPrjId: subPrjId, onlyBe1Flag: onlyBe1Flag, siteId: siteId, serviceCode: serviceCode,
          currentInspectionNum: currentInspectionNum, currentInspectionMoney: currentInspectionMoney, sumMoney: sumMoney,
          sumNum: sumNum, projectProgress: projectProgress, inspectionTax: inspectionTax, inspectionTaxAmount: inspectionTaxAmount,
          orderDetailId: orderDetailId, purchaseMode: purchaseMode, payType: this.form.payType, flag: '1', oldSumMoney: this.oldSumMoney, oldSumNum: this.oldSumNum
        }
      }
      if (this.flagVal === '2') {
        _backdata = {
          vId: vId, pId: pId, currentInspectionNum: currentInspectionNum, currentInspectionMoney: currentInspectionMoney,
          projectProgress: projectProgress, onlyBe1Flag: onlyBe1Flag, sumNum: sumNum, sumMoney: sumMoney,
          serviceCode: serviceCode, prjId: prjId, subPrjId: subPrjId, inspectionTax: inspectionTax, inspectionTaxAmount: inspectionTaxAmount, flag: '2', oldSumMoney: this.oldSumMoney, oldSumNum: this.oldSumNum
        }
      }
      return _backdata
    },
    async repairNewSaveTwentySix(dataVal, onlyBe1Flag, allServiceSumNum, allServiceTServListAmount, sumMoney, shMoney, sumNum, shNum, projectProgress) {
      if (this.newOldProject === '1') { // 老项目的时候onlybe1FLAG校验
        await this.repairNewSaveTwentySeven(onlyBe1Flag, allServiceSumNum, allServiceTServListAmount, sumNum, projectProgress)
        // 保存传的数据
        await this.repairNewSaveTwentyNine(dataVal, onlyBe1Flag, sumMoney, shMoney, sumNum, shNum)
      } else {
        await this.repairNewSaveTwentyEight(allServiceSumNum, allServiceTServListAmount, sumNum, projectProgress)
        // 保存传的数据
        await this.repairNewSaveThirtyTwo(dataVal, sumMoney, shMoney, sumNum, shNum)
      }
     },
    async repairNewSaveTwentySeven(onlyBe1Flag, allServiceSumNum, allServiceTServListAmount, sumNum, projectProgress) {
      const flagshow = this.editType === '1' && onlyBe1Flag === 'N' && allServiceSumNum === allServiceTServListAmount
      if (flagshow && sumNum !== '0' && projectProgress !== '100') {
          this.$message({
            message: '当前服务编码所有预估单累计验工数量等于设计方案中数量，需要将项目进度填为100！',
            type: 'warning'
          })
          return Promise.reject()
        }
    },
    async repairNewSaveTwentyEight(allServiceSumNum, allServiceTServListAmount, sumNum, projectProgress) {
      if (this.editType === '1' && allServiceSumNum === allServiceTServListAmount && sumNum !== 0 && projectProgress !== '100') {
          this.$message({
            message: '当前服务编码所有预估单累计验工数量等于设计方案中数量，需要将项目进度填为100！',
            type: 'warning'
          })
          return Promise.reject()
        }
    },
    async repairNewSaveTwentyNine(dataVal, onlyBe1Flag, sumMoney, shMoney, sumNum, shNum) {
      if (this.editType === '1') {
          await this.repairNewSaveThirty(dataVal, onlyBe1Flag, sumMoney, shMoney, sumNum, shNum)
        } else {
          console.log(onlyBe1Flag, sumMoney, sumNum)
         await this.repairNewSaveThirtyOne(dataVal, onlyBe1Flag, sumMoney, sumNum)
        }
    },
    async repairNewSaveThirty(dataVal, onlyBe1Flag, sumMoney, shMoney, sumNum, shNum) {
      const flags = (onlyBe1Flag === 'Y' && Number(sumMoney) === Number(shMoney))
      if (flags || (onlyBe1Flag === 'N' && Number(sumNum) === Number(shNum))) {
        this.$confirm('本次验工计价新增完成后，当前商合服务订单的验工计价已经全部验满，请知晓！服务订单【累计验工数量】=' + sumNum + '，【累计验工金额】=' + sumMoney, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          cancelButtonClass: 'pms-zr-button',
          confirmButtonClass: 'pms-zr-button-primary',
          type: 'warning'
        }).then(() => {
          this.initSaveData(dataVal)
        })
      } else {
        this.initSaveData(dataVal)
      }
    },
    async repairNewSaveThirtyOne(dataVal, onlyBe1Flag, sumMoney, sumNum) {
      if ((onlyBe1Flag === 'Y' && sumMoney === 0) || (onlyBe1Flag === 'N' && sumNum === 0)) {
            this.$confirm('本次验工计价冲销完成后，当前商合服务订单的验工计价已经全部冲销，请知晓！服务订单【累计验工数量】=' + sumNum + '，【累计验工金额】=' + sumMoney, '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              cancelButtonClass: 'pms-zr-button',
              confirmButtonClass: 'pms-zr-button-primary',
              type: 'warning'
            }).then(() => {
              this.initSaveData(dataVal)
            })
          } else {
            this.initSaveData(dataVal)
          }
    },
    async repairNewSaveThirtyTwo(dataVal, sumMoney, shMoney, sumNum, shNum) {
      if (this.editType === '1') {
          await this.repairNewSaveThirtyThree(dataVal, sumMoney, shMoney, sumNum, shNum)
        } else {
          await this.repairNewSaveThirtyFour(dataVal, sumMoney, sumNum)
        }
    },
    async repairNewSaveThirtyThree(dataVal, sumMoney, shMoney, sumNum, shNum) {
      if (Number(sumMoney) === Number(shMoney) || Number(sumNum) === Number(shNum)) {
            this.$confirm('本次验工计价新增完成后，当前商合服务订单的验工计价已经全部验满，请知晓！服务订单【累计验工数量】=' + sumNum + '，【累计验工金额】=' + sumMoney, '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              cancelButtonClass: 'pms-zr-button',
              confirmButtonClass: 'pms-zr-button-primary',
              type: 'warning'
            }).then(() => {
              this.initSaveData(dataVal)
            })
          } else {
            this.initSaveData(dataVal)
          }
     },
    async repairNewSaveThirtyFour(dataVal, sumMoney, sumNum) {
      if (sumMoney === 0 || sumNum === 0) {
            this.$confirm('本次验工计价冲销完成后，当前商合服务订单的验工计价已经全部冲销，请知晓！服务订单【累计验工数量】=' + sumNum + '，【累计验工金额】=' + sumMoney, '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              cancelButtonClass: 'pms-zr-button',
              confirmButtonClass: 'pms-zr-button-primary',
              type: 'warning'
            }).then(() => {
              this.initSaveData(dataVal)
            })
          } else {
            this.initSaveData(dataVal)
          }
     },
    // 新增||修改||删除 保存校验
    async newSave() {
      await this.repairNewSaveOne()
      console.log(this.oldSumMoney, this.oldSumNum, 'this.oldSumMoneythis.oldSumNum ')
      console.log(this.editType, 'this.editType')
      this.$refs.form.validate(async(valid) => {
        if (valid) {
          // 携带数据
          var fatherArr = ''
          var vId = ''
          var pId = ''
          var prjId = ''
          var subPrjId = ''
          var onlyBe1Flag = ''
          var serviceCode = ''
          var siteId = ''
          var currentInspectionMoney = ''
          var currentInspectionNum = ''
          var projectProgress = ''
          var sumMoney = ''
          var sumNum = ''
          var payType = ''
          var shMoney = ''
          var taxrate = ''
          var shNum = ''
          var price = ''
          var orderDetailId = ''
          var purchaseMode = ''
          if (this.formIfType === '1') {
            // 判断点击的是不是修改
            fatherArr = this.newSeltVal()
            vId = this.yanGongArr[0].vid // 修改的时候拿到这条的vId
            pId = fatherArr[0].vid // 数据ID 新增,冲销 传的都是vid (vid代表所有的子项目pid)
            prjId = fatherArr[0].prjId // 项目ID
            subPrjId = fatherArr[0].subPrjId // 子项目ID
            onlyBe1Flag = fatherArr[0].onlybe1FLAG // 服务数量是否为1
            serviceCode = fatherArr[0].serviceCode
            siteId = fatherArr[0].siteId
            currentInspectionMoney = this.form.currentInspectionMoney // 转下字符串 用来校验
            currentInspectionNum = this.form.currentInspectionNum //
            projectProgress = this.form.projectProGress
            sumMoney = this.form.sumMoney // 该订单累计验工金额
            sumNum = this.form.sumNum// 该订单累计验工数量
            payType = this.form.payType // 弹框类型
            shMoney = fatherArr[0].shMoney // 商合预占金额
            taxrate = fatherArr[0].taxrate // 税率
            shNum = fatherArr[0].shNum // 商合预占数量
            price = fatherArr[0].price // 单价
            orderDetailId = fatherArr[0].orderDetailId // 商合唯一标识
            purchaseMode = fatherArr[0].purchaseMode // 电商化非电商化标识
          } else {
            pId = this.selectionVal[0].vid // 数据ID 新增,冲销 传的都是vid (vid代表所有的子项目pid)
            prjId = this.selectionVal[0].prjId // 项目ID
            subPrjId = this.selectionVal[0].subPrjId // 子项目ID
            onlyBe1Flag = this.selectionVal[0].onlybe1FLAG // 服务数量是否为1
            serviceCode = this.selectionVal[0].serviceCode
            siteId = this.selectionVal[0].siteId
            currentInspectionMoney = this.form.currentInspectionMoney // 转下字符串 用来校验
            currentInspectionNum = this.form.currentInspectionNum //
            projectProgress = this.form.projectProGress
            sumMoney = this.form.sumMoney // 该订单累计验工金额
            sumNum = this.form.sumNum// 该订单累计验工数量
            payType = this.form.payType // 弹框类型
            shMoney = this.selectionVal[0].shMoney // 商合预占金额
            taxrate = this.selectionVal[0].taxrate // 税率
            shNum = this.selectionVal[0].shNum // 商合预占数量
            price = this.selectionVal[0].price // 单价
            orderDetailId = this.selectionVal[0].orderDetailId // 商合唯一标识
            purchaseMode = this.selectionVal[0].purchaseMode // 电商化非电商化标识
          }

          //  只对旧总包校验
          /** 三包服务编码只能填写整数 微站EPC总包服务编码规则：PMS服务编码以90050111开头，但不含9005011109开头服务编码；
           微站施工总包服务编码规则：PMS服务编码以90050110开头，但不含9005011009开头服务编码；
           新疆机房总承包服务编码规则：9001011008、9002010802、9003010202、9005011010开头的；
           */
          var epcServiceType = ''
          const object = {
            materialCode: serviceCode
          }
          const getMaterialInfo = await getMaterialInfoNew(object)

          if (getMaterialInfo.code === '200') {
            epcServiceType = getMaterialInfo.data.epcServiceType
          }
          // var r = /^[1-9]\d*|0$/ // 正整数+0
          await this.repairNewSaveTwo(epcServiceType, currentInspectionNum)
          // 保存新增验工计价场景校验：
          await this.repairNewSaveThree(onlyBe1Flag, currentInspectionMoney, currentInspectionNum, sumMoney, shMoney, projectProgress, sumNum, shNum)
          await this.repairNewSaveFour(onlyBe1Flag, sumNum, shNum, projectProgress, currentInspectionMoney, price, currentInspectionNum, shMoney)
          await this.repairNewSaveFive(projectProgress, currentInspectionMoney, currentInspectionNum)
          // 下一个判断
          await this.repairNewSaveSix(onlyBe1Flag, sumNum, shNum)
          await this.repairNewSaveSeven(sumNum, sumMoney, shMoney)
          // 保存验工计价通用校验 ↓
          var flag = false
          var allServiceSumNum = 0 // 服务所有订单下累计验工数量
          var allServiceShNumSum = 0 // 服务所有订单下商合预占数量的和
          var allServiceTServListAmount = 0 // 设计表服务数量
          var allServiceTServListAdjAmount = 0 // 设计变更表服务数量
          var allSupplementNum = 0 // 在建工程损失补采数量
          var minSumNum = 0
          // var allServiceSumMoney = 0 // 服务所有订单下累计验工金额
          // var allServiceShMoneySum = 0 // 服务所有订单下商合预占金额的和
          // var allServiceTServListEquipSum = 0 // 设计表服务及金额
          // var allServiceTServListAdjEquipSum = 0 // 设计变更表服务及金额

          const obj = {
            serviceCode: serviceCode,
            subPrjId: subPrjId,
            prjId: prjId
          }

          const ifEngineeringVisa = await ifEngineeringVisaNew({ serviceCode: serviceCode })
          console.log(ifEngineeringVisa.data, 'ifEngineeringVisa.data')

          const gCheckData = await getCheckInsVaDataNew(obj)
          if (gCheckData.code === '200') {
            allServiceSumNum = await this.repairNewSaveEight(gCheckData, allServiceSumNum, currentInspectionNum)
            allServiceShNumSum = gCheckData.data.shSum.SH_NUM_SUM
            allSupplementNum = await this.repairNewSaveNine(gCheckData, allSupplementNum)
            allServiceTServListAmount = await this.repairNewSaveTen(gCheckData, allServiceTServListAmount, allSupplementNum)
            const { backdata1, backdata2 } = await this.repairNewSaveTweleve(gCheckData, allServiceTServListAdjAmount, allSupplementNum, allServiceShNumSum, allServiceTServListAmount, minSumNum)
            allServiceTServListAdjAmount = backdata1
            minSumNum = backdata2
            // 验工计价进度为100时候
            var bijiaoVal = ''
            bijiaoVal = await this.repairNewSaveThirteen(bijiaoVal, projectProgress)
            const desGrossWight = minSumNum * this.sunmNumMin
            const desGrossWightNumb = this.sunmNumMin * 100 // 设计总量的 小数乘100
            await this.repairNewSaveFourteen(bijiaoVal, desGrossWight, desGrossWightNumb, serviceCode, currentInspectionMoney, taxrate, pId, prjId, subPrjId, onlyBe1Flag, siteId, currentInspectionNum, sumMoney, sumNum, projectProgress, orderDetailId, purchaseMode, vId)
            console.log(minSumNum, 'minSumNum ')
            console.log(allServiceSumNum, onlyBe1Flag, 'allServiceSumNum')
            await this.repairNewSaveFiveteen(onlyBe1Flag, allServiceSumNum, minSumNum, ifEngineeringVisa, gCheckData, sumNum, serviceCode)
          }

          // 冲销的校验
          await this.repairNewSaveEightteen(currentInspectionNum, currentInspectionMoney, pId, prjId, subPrjId, serviceCode, payType, onlyBe1Flag, shNum, shMoney)
          await this.repairNewSaveTwentyFour(onlyBe1Flag, sumNum, shNum, sumMoney, shMoney)
          var inspectionTax = Number(currentInspectionMoney) * Number(taxrate) // 验工计价税额 = 本期验工金额*税率
          inspectionTax = this.farmatMoney(inspectionTax)
          const inspectionTaxAmount = this.farmatMoney(Number(currentInspectionMoney) + Number(inspectionTax)) // 含税验工计价总金额 = 本期验工金额 + 验工计价税额
          var dataVal = []
          dataVal = await this.repairNewSaveTwentyFive(vId, pId, prjId, subPrjId, onlyBe1Flag, siteId, serviceCode, currentInspectionNum, currentInspectionMoney, sumMoney, sumNum, projectProgress, inspectionTax, inspectionTaxAmount, orderDetailId, purchaseMode)
          await this.repairNewSaveTwentySix(dataVal, onlyBe1Flag, allServiceSumNum, allServiceTServListAmount, sumMoney, shMoney, sumNum, shNum, projectProgress)
          return
        }
      })
    },
      // 保存
      async initSaveData(data) {
        const updateInsVaDetails = await updateInsVaDetailsNew(data)
        if (updateInsVaDetails.code === '200') {
            this.listData() // 刷新列表
            this.dialogVisible = false
            this.close() // 调用关闭清空表单
            // this.dialogClosed() // 外部关闭弹框
            this.$message({
                message: updateInsVaDetails.message,
                type: 'success'
            })
        }
      },
      farmatNum(Num) { // 四舍五入保留4位小数
        var pum = 0
        var value = ''
        if (Num < 0) {
          pum = -Num
        } else {
          pum = Num
        }
        value = Math.round(Number(pum) * Math.pow(10, 4)) / Math.pow(10, 4)
        // if (this.newOldProject === '1') {
        // } else {
        //   value = Math.round(Number(pum) * Math.pow(10, 9)) / Math.pow(10, 9)
        // }
        if (Num < 0) {
          return -value
        } else {
          return value
        }
      },
      farmatMoney(money) { // 四舍五入保留2位小数
            var pum = 0
            var value = ''
            if (money < 0) {
                pum = -money
            } else {
                pum = money
            }
            value = Math.round(pum * Math.pow(10, 2)) / Math.pow(10, 2)
            // if (this.newOldProject === '1') {
            //   value = Math.round(pum * Math.pow(10, 9)) / Math.pow(10, 9)
            // } else {
            //   value = Number(pum)
            // }
            if (money < 0) {
                return -value
            } else {
                return value
            }
      },
      onValuechangedPayType(e) {
        if (this.formIfType === '1') {
          // 判断点击的是不是修改
          this.getServeCodeData = this.newSeltVal() // 获取父项目信息
        } else {
          this.getServeCodeData = this.yuGuDanArr
        }
        if (e === 'FIRST' && this.firstNum === '0' && this.editType === '2') {
            this.form.currentInspectionNum = '0'
            this.currentInspectionNumShow = true
            this.form.currentInspectionMoney = (-this.firstMoney)
            this.currentInspectionMoneyShow = true
            this.form.projectProGress = '100'
            this.projectProGressShow = true
            this.form.sumNum = this.getServeCodeData[0].sumNum // 赋值传过来的sumNum数据
            var sumMoney = this.farmatMoney(this.farmatMoney(-this.firstMoney) + this.farmatMoney(this.getServeCodeData[0].sumMoney))
            console.log(sumMoney, this.farmatMoney(-this.firstMoney), this.farmatMoney(this.getServeCodeData[0].sumMoney), 'sumMoney')
            this.form.sumMoney = sumMoney
        }else{
          this.form.projectProGress = ''
          this.form.currentInspectionNum = ''
          this.form.currentInspectionMoney = ''
          this.form.sumNum = ''
          this.form.sumMoney = ''
          this.projectProGressShow = false
          this.currentInspectionNumShow = false
        }
      },
      async onValuechanged(e) {
        var sumMoney = ''
        if (this.formIfType === '1') {
          // 判断点击的是不是修改
          this.oldSumMoney = this.newSeltVal()[0].sumMoney // 获取父项目信息
          sumMoney = this.farmatMoney(this.farmatMoney(e) + this.farmatMoney(this.oldSumMoney) - this.farmatMoney(this.postOldCurrMony))
        } else {
          this.oldSumMoney = this.yuGuDanArr[0].sumMoney
          console.log(e, 'kaka', this.oldSumMoney)
          sumMoney = this.farmatMoney(this.farmatMoney(e) + this.farmatMoney(this.oldSumMoney))
        }
        if (this.ifNewPost === '冲销验工计价' && this.form.payType === 'PROGRESSING') { // 本期金额如果小于0证明是冲销 并且为 进度款时候(0528冲销时,验工计价包含损失款时)
          const getSumLossByVid = await getSumLossByVidNew({ vid: this.yuGuDanArr[0].vid })
            if (getSumLossByVid.code === '200') {
              console.log(this.form.sumMoney, '和1', sumMoney)
              this.form.sumMoney = this.farmatMoney(sumMoney - Math.abs(getSumLossByVid.data.SUM_MONEY_LOSS))
            }
        } else {
          this.form.sumMoney = sumMoney
        }
        console.log(sumMoney, 'sumMoneysumMoneysumMoney')
        // this.form.sumMoney = sumMoney
      },
      onValuechanged1(e) {
        var cost = e
        if (isFinite(parseFloat(cost))) {
          cost = this.farmatNum(cost)
          this.form.currentInspectionNum = this.farmatNum(cost)
        }
        this.initFormData(cost)
      },
      async initFormDatarepairOne(getSumLossByVid, cost) {
        let backgetSumLossByVid = getSumLossByVid
        if (this.formIfType === '1') {
          // 判断点击的是不是修改 修改走负计算
          this.getServeCodeData = this.newSeltVal() // 获取父项目信息
          this.form.currentInspectionMoney = this.farmatMoney(Number(cost) * Number(this.getServeCodeData[0].price)) // 计算本期验工金额    本期验工数量*单价
          this.form.sumMoney = this.farmatMoney(this.farmatMoney(this.form.currentInspectionMoney) + (Number(this.getServeCodeData[0].sumMoney) - Number(this.currentDataCurrentInspectionMoney))) // 计算累计验工金额   当前输入本期验工金额+(累计金额 -当前验工计价金额)
          this.form.sumNum = this.farmatNum(Number(cost) + (Number(this.getServeCodeData[0].sumNum) - Number(this.currentDataCurrentInspectionNum)))// 修改计算累计验工数量   当前输入本期验工数量+(表里累计数量-当前数据本验工计数量)
          console.log(this.form.sumMoney, '走进科学1', this.form.currentInspectionMoney)
        } else {
          console.log('走进科学2', this.form.currentInspectionNum, this.form.currentInspectionNum < 0, this.form.payType === 'PROGRESSING')
          backgetSumLossByVid = await this.initFormDatarepairTwo(backgetSumLossByVid, cost)
        }
        return backgetSumLossByVid
      },
      async initFormDatarepairTwo(backgetSumLossByVid, cost) {
        let _deepdata = backgetSumLossByVid
        if (this.ifNewPost === '冲销验工计价' && this.form.payType === 'PROGRESSING') { // 本期金额如果小于0证明是冲销 并且为 进度款时候(0528冲销时,验工计价包含损失款时)
          _deepdata = await getSumLossByVidNew({ vid: this.yuGuDanArr[0].vid })
         await this.initFormDatarepairThree(_deepdata, cost)
        } else {
          this.form.currentInspectionMoney = this.farmatMoney(Number(cost) * Number(this.selectionVal[0].price)) // 计算本期验工金额    本期验工数量*单价
          this.form.sumMoney = this.farmatMoney(this.farmatMoney(this.form.currentInspectionMoney) + Number(this.selectionVal[0].sumMoney)) // 计算累计验工金额   本期验工金额+其他子类验工金额的和（sumMoney）
          this.form.sumNum = this.farmatNum(Number(cost) + Number(this.selectionVal[0].sumNum))// 新增计算累计验工数量    本期验工数量+其他子类验工数量的和（sumNum）
          console.log(this.form.sumMoney, '走进科学没冲销', this.yuGuDanArr[0], this.form.currentInspectionMoney)
        }
        return _deepdata
      },
      async initFormDatarepairThree(_deepdata, cost) {
        if (_deepdata.code === '200') {
            const sumNumNewVal = this.farmatNum(Number(cost) + Number(this.selectionVal[0].sumNum))// 新增计算累计验工数量    本期验工数量+其他子类验工数量的和（sumNum）
            if (sumNumNewVal === Math.abs(_deepdata.data.SUM_MONEY_LOSS)) {
              this.form.sumMoney = this.farmatMoney(Number(sumNumNewVal) * Number(this.selectionVal[0].price))
              this.form.currentInspectionMoney = this.farmatNum(Number(sumNumNewVal) * Number(this.selectionVal[0].price) - Number(this.selectionVal[0].sumMoney))// 新增计算累计验工数量 // 计算本期验工金额    本期验工数量*单价
            } else {
              this.form.currentInspectionMoney = this.farmatMoney(Number(cost) * Number(this.selectionVal[0].price)) // 计算本期验工金额    本期验工数量*单价
              const sumMoneyNewVal = this.farmatMoney(this.farmatMoney(this.form.currentInspectionMoney) + Number(this.selectionVal[0].sumMoney)) // 计算累计验工金额   本期验工金额+其他子类验工金额的和（sumMoney）
              this.form.sumMoney = this.farmatNum(sumMoneyNewVal)
            }
            this.form.sumNum = this.farmatNum(sumNumNewVal)
            console.log(this.form.sumMoney, '走进科学冲销')
          }
      },
      async initFormDatarepairFour(cost) {
        if (cost < 0) {
          console.log('走进科学3')
          this.currentInspectionMoneyShow = false
          this.form.projectProGress = '0'
          this.projectProGressShow = true
        }
         if (cost > 0 && this.form.projectProGress !== '100') {
          console.log('走进科学4')
          this.projectProGressShow = false
          this.currentInspectionMoneyShow = true
        }
      },
      async initFormDatarepairFive(getSumLossByVid) {
        console.log(getSumLossByVid,"test");
        if (this.selectionVal[0].onlybe1FLAG === 'N' && this.form.sumNum === 0) {
          if (this.ifNewPost === '冲销验工计价' && this.form.payType === 'PROGRESSING') { // 本期金额如果小于0证明是冲销 并且为 进度款时候(0528冲销时,验工计价包含损失款时)
            this.form.currentInspectionMoney = this.farmatNum(0 - (Number(this.selectionVal[0].sumMoney) - Math.abs(getSumLossByVid.data.SUM_MONEY_LOSS))) // 累计验工计价数量如果为0   则本期验
          } else {
            this.form.currentInspectionMoney = this.farmatNum(0 - this.selectionVal[0].sumMoney) // 累计验工计价数量如果为0   则本期验
          }
          this.form.sumMoney = 0 // 累计验工计价数量如果为0   则累计验工金额自动带入0
          console.log(this.form.sumMoney, '走进科学6', this.form.currentInspectionMoney, Number(this.selectionVal[0].sumMoney))
        }
      },
      async initFormData(costData) {
        let getSumLossByVid = ''
        var cost = costData
        // if (this.formIfType === '1') {
        //   // 判断点击的是不是修改 修改走负计算
        //   this.getServeCodeData = this.newSeltVal() // 获取父项目信息
        //   this.form.currentInspectionMoney = this.farmatMoney(Number(cost) * Number(this.getServeCodeData[0].price)) // 计算本期验工金额    本期验工数量*单价
        //   this.form.sumMoney = this.farmatMoney(this.farmatMoney(this.form.currentInspectionMoney) + (Number(this.getServeCodeData[0].sumMoney) - Number(this.currentDataCurrentInspectionMoney))) // 计算累计验工金额   当前输入本期验工金额+(累计金额 -当前验工计价金额)
        //   this.form.sumNum = this.farmatNum(Number(cost) + (Number(this.getServeCodeData[0].sumNum) - Number(this.currentDataCurrentInspectionNum)))// 修改计算累计验工数量   当前输入本期验工数量+(表里累计数量-当前数据本验工计数量)
        //   console.log(this.form.sumMoney, '走进科学1', this.form.currentInspectionMoney)
        // } else {
        //   console.log('走进科学2', this.form.currentInspectionNum, this.form.currentInspectionNum < 0, this.form.payType === 'PROGRESSING')
        //   if (this.ifNewPost === '冲销验工计价' && this.form.payType === 'PROGRESSING') { // 本期金额如果小于0证明是冲销 并且为 进度款时候(0528冲销时,验工计价包含损失款时)
        //     getSumLossByVid = await getSumLossByVidNew({ vid: this.yuGuDanArr[0].vid })
        //     if (getSumLossByVid.code === '200') {
        //       const sumNumNewVal = this.farmatNum(Number(cost) + Number(this.selectionVal[0].sumNum))// 新增计算累计验工数量    本期验工数量+其他子类验工数量的和（sumNum）
        //         if (sumNumNewVal === Math.abs(getSumLossByVid.data.SUM_MONEY_LOSS)) {
        //             this.form.sumMoney = this.farmatMoney(Number(sumNumNewVal) * Number(this.selectionVal[0].price))
        //             this.form.currentInspectionMoney = this.farmatNum(Number(sumNumNewVal) * Number(this.selectionVal[0].price) - Number(this.selectionVal[0].sumMoney))// 新增计算累计验工数量 // 计算本期验工金额    本期验工数量*单价
        //         } else {
        //             this.form.currentInspectionMoney = this.farmatMoney(Number(cost) * Number(this.selectionVal[0].price)) // 计算本期验工金额    本期验工数量*单价
        //             const sumMoneyNewVal = this.farmatMoney(this.farmatMoney(this.form.currentInspectionMoney) + Number(this.selectionVal[0].sumMoney)) // 计算累计验工金额   本期验工金额+其他子类验工金额的和（sumMoney）
        //             this.form.sumMoney = this.farmatNum(sumMoneyNewVal)
        //         }
        //       this.form.sumNum = this.farmatNum(sumNumNewVal)
        //       console.log(this.form.sumMoney, '走进科学冲销')
        //     }
        //   } else {
        //     this.form.currentInspectionMoney = this.farmatMoney(Number(cost) * Number(this.selectionVal[0].price)) // 计算本期验工金额    本期验工数量*单价
        //     this.form.sumMoney = this.farmatMoney(this.farmatMoney(this.form.currentInspectionMoney) + Number(this.selectionVal[0].sumMoney)) // 计算累计验工金额   本期验工金额+其他子类验工金额的和（sumMoney）
        //     this.form.sumNum = this.farmatNum(Number(cost) + Number(this.selectionVal[0].sumNum))// 新增计算累计验工数量    本期验工数量+其他子类验工数量的和（sumNum）
        //     console.log(this.form.sumMoney, '走进科学没冲销', this.yuGuDanArr[0], this.form.currentInspectionMoney)
        //   }
        // }
        getSumLossByVid= await this.initFormDatarepairOne(getSumLossByVid, cost)
        await this.initFormDatarepairFour(cost)
        if (this.selectionVal[0].onlybe1FLAG === 'N' && this.form.sumNum >= this.selectionVal[0].shNum) {
          this.form.sumMoney = this.selectionVal[0].shMoney // 累计数量=商合预占数   则自动将商合预占金额带入累计预占金额，本期验工金额等于预占金额减去历史累计验工金额
          this.form.currentInspectionMoney = this.farmatNum(this.selectionVal[0].shMoney - this.selectionVal[0].sumMoney) // 累计数量=商合预占数    则累计金额则自动将商合预占金额带入，本期验工金额等于预占金额减去历史累计验工金额
          console.log(this.form.sumMoney, '走进科学5', this.form.currentInspectionMoney)
        }
        await this.initFormDatarepairFive(getSumLossByVid)
      },
      async onValuechanged2repairOne() {
        if (this.formIfType === '1') {
          // 判断点击的是不是修改
          this.getServeCodeData = this.newSeltVal() // 获取父项目信息(修改时候查的父项目信息)
        } else {
          this.getServeCodeData = this.yuGuDanArr // 获取父项目信息
        }
      },
      async onValuechanged2repairTwo() {
        if (this.getServeCodeData[0].onlybe1FLAG === 'N') {
         await this.onValuechanged2repairFour()
        }
      },
      async onValuechanged2repairThree() {
        if (this.form.projectProGress === '100') {
            this.currentInspectionMoneyShow = false
          } else {
            this.currentInspectionMoneyShow = true
            var cost1 = this.form.currentInspectionNum
            if (isFinite(parseFloat(cost1))) {
              cost1 = this.farmatNum(cost1)
            }
            this.initFormData(cost1)
          }
      },
      async onValuechanged2repairFour() {
        if (this.form.projectProGress === '100') {
            this.currentInspectionMoneyShow = false
          } else {
            this.currentInspectionMoneyShow = true
            var cost = this.form.currentInspectionNum
            if (isFinite(parseFloat(cost))) {
              cost = this.farmatNum(cost)
            }
            this.initFormData(cost)
          }
      },
     async onValuechanged2(e) {
        await this.onValuechanged2repairOne()
        if (this.newOldProject === '1') { // 老项目的时候onlybe1FLAG校验
          await this.onValuechanged2repairTwo()
        } else {
          await this.onValuechanged2repairThree()
        }
      },
      handleEdit(row, event, column) {
        this.$set(row, 'isOk', true)
        this.oldCspectionNum = row.currentInspectionNum
        this.oldCspectionMoney = row.currentInspectionMoney
      },
      handleEditTwo(row, event, column) {
        this.$set(row, 'isOk2', true)
        this.oldCspectionNum = row.currentInspectionNum
        this.oldCspectionMoney = row.currentInspectionMoney
      },
      handleBlur(row, event, column) {
        this.$set(row, 'isOk', false)
        this.onCellValidation(row)
        row.currentInspectionNum = this.farmatNum(row.currentInspectionNum)
        row.currentInspectionMoney = this.farmatMoney(Number(row.currentInspectionNum) * Number(row.price))
      },
      handleBlurTwo(row, event, column) {
        this.$set(row, 'isOk2', false)
        this.onCellValidation(row)
        row.currentInspectionMoney = this.farmatMoney(row.currentInspectionMoney)
      },
      // 批量新增改变行的颜色
      styleBack(row) {
        if (row.columnIndex === 13 || row.columnIndex === 14) {
          return { backgroundColor: '#fceee2' }
        }
      },
      cellClick(row, event, column) {
        console.log(row, event, column)
      },
      async onCellValidationrepairOne(record) {
        if (isNaN(record.currentInspectionNum) || isNaN(record.currentInspectionMoney)) {
          this.$message({
            message: '非法字符!',
            type: 'warning'
          })
          this.isValid = false
          return Promise.reject()
        } else {
          this.isValid = true
        }
      },
      async onCellValidationrepairTwo(record) {
        if (Number(record.currentInspectionNum) <= 0) {
            this.$message({
                message: '批量新增功能本期验工数量必须填写正数!',
                type: 'warning'
              })
              this.isValid = false
              return Promise.reject()
            } else {
              this.isValid = true
            }
      },
      async onCellValidationrepairThree(record) {
        if (Number(record.currentInspectionNum) > this.oldCspectionNum) {
            this.$message({
                message: '当前预估单的累计验工数量应小于等于商合预占数!',
                type: 'warning'
              })
              this.isValid = false
              return Promise.reject()
            } else {
              this.isValid = true
            }
      },
      async onCellValidationrepairFour(record) {
        if (Number(record.currentInspectionMoney) > this.oldCspectionMoney) {
            this.$message({
              message: '当前预估单的累计验工金额应小于等于商合预占金额！',
              type: 'warning'
            })
            return Promise.reject()
          }
      },
      async onCellValidationrepairFive(currentinSpectionMoney, record, totalNum, shNum) {
        if ((((currentinSpectionMoney - this.floataMountMax) > Number(record.currentInspectionMoney)) || ((currentinSpectionMoney + this.floataMountMax) < Number(record.currentInspectionMoney))) && Number(totalNum) !== Number(shNum)) {
             this.$message({
               message: '调整区间为系统自动计算金额上下浮动' + this.floataMountMax + '元',
               type: 'warning'
             })
             return Promise.reject()
           }
      },
      async onCellValidationrepairSix(currentinSpectionMoney, record, totalNum, shNum) {
        if ((((currentinSpectionMoney - this.floataMountMax) > Number(record.currentInspectionMoney)) || ((currentinSpectionMoney + this.floataMountMax) < Number(record.currentInspectionMoney))) && Number(totalNum) !== Number(shNum)) {
           this.$message({
             message: '调整区间为系统自动计算金额上下浮动' + this.floataMountMax + '元',
             type: 'warning'
           })
           return Promise.reject()
         }
      },
      // 失去 焦点调用的事件
     async onCellValidation(row) {
        var record = row
        var price = record.price
        var currentTinSpectionNum = this.farmatNum(record.currentInspectionNum)
        var currentinSpectionMoney = this.farmatMoney(currentTinSpectionNum * price)
        var shNum = record.shNum
        var sumNum = record.sumNum
        var totalNum = this.farmatNum(Number(sumNum) + Number(currentTinSpectionNum))
        await this.onCellValidationrepairOne(record)
        await this.onCellValidationrepairTwo(record)
				await this.onCellValidationrepairThree(record)
        await this.onCellValidationrepairFour(record)
       if (this.newOldProject === '1') { // 老项目的时候onlybe1FLAG校验
         if (record.onlybe1FLAG === 'N') {
           await this.onCellValidationrepairFive(currentinSpectionMoney, record, totalNum, shNum)
         }
       } else {
         await this.onCellValidationrepairSix(currentinSpectionMoney, record, totalNum, shNum)
       }
      },
      // 批量新增保存 校验
      allSave() {
        if (this.detailFormData.length > 0) {
          // 验证成功
          if (this.isValid === true) {
             this.initData(this.detailFormData)
          } else {
              this.$message({
                message: '数据有误，请修改后保存！',
                type: 'warning'
            })
          }
        } else {
          this.$message({
            message: '暂未可保存的数据！',
            type: 'warning'
          })
        }
      },
      async initDatarepairOne(epcServiceType, r, record) {
        if (epcServiceType === '1' && !r.test(Math.abs(record.currentInspectionNum))) {
          this.$message({
            message: '该服务编码属于微站EPC总包服务编码,验工计价数量只能填写正整数，请修改！',
            type: 'warning'
          })
          return Promise.reject()
        }
        if (epcServiceType === '2' && !r.test(Math.abs(record.currentInspectionNum))) {
          this.$message({
            message: '该服务编码属于微站施工总包服务编码,验工计价数量只能填写正整数，请修改！',
            type: 'warning'
          })
          return Promise.reject()
        }
      },
      async initDatarepairTwo(epcServiceType, r, record) {
        if (epcServiceType === '3' && !r.test(Math.abs(record.currentInspectionNum))) {
          this.$message({
            message: '该服务编码属于新疆机房总承包服务编码,验工计价数量只能填写正整数，请修改！',
            type: 'warning'
          })
          return Promise.reject()
        }
      },
      async initDatarepairThree(gCheckData, allSupplementNum) {
        let backallSupplementNum = allSupplementNum
        if (gCheckData.data.supplementNum.SUPPLEMENT_NUM) {
          backallSupplementNum = gCheckData.data.supplementNum.SUPPLEMENT_NUM // 在建工程损失补采数量
        }
        return backallSupplementNum
      },
      async initDatarepairFour(minSumNum, allServiceShNumSum, allServiceTServListAmount) {
        let backminSumNum = minSumNum
        if (allServiceShNumSum > allServiceTServListAmount) {
          backminSumNum = allServiceTServListAmount
        } else {
          backminSumNum = allServiceShNumSum
        }
        return backminSumNum
      },
      async initDatarepairFive(allServiceShNumSum, allServiceTServListAmount, allServiceTServListAdjAmount) {
        return allServiceShNumSum < allServiceTServListAmount ? (allServiceShNumSum < allServiceTServListAdjAmount ? allServiceShNumSum : allServiceTServListAdjAmount) : (allServiceTServListAmount < allServiceTServListAdjAmount ? allServiceTServListAmount : allServiceTServListAdjAmount)
      },
      async initDatarepairSix(gCheckData) {
        return gCheckData.data.serListAdjSum.SJ_ADJ_AMOUNT || gCheckData.data.serListAdjSum.SJ_ADJ_MONEY
      },
      async initDatarepairSeven(onlyBe1Flag, allServiceSumNum, minSumNum, siteId, serviceCode) {
        if (this.newOldProject === '1') { // 老项目的时候onlybe1FLAG校验
          await this.initDatarepairEight(onlyBe1Flag, allServiceSumNum, minSumNum, siteId, serviceCode)
        } else {
          await this.initDatarepairNine(onlyBe1Flag, allServiceSumNum, minSumNum, siteId, serviceCode)
        }
      },
      async initDatarepairEight(onlyBe1Flag, allServiceSumNum, minSumNum, siteId, serviceCode) {
        if (onlyBe1Flag === 'N' && allServiceSumNum > minSumNum) {
            this.$message({
              message: '站址编码：' + siteId + '，服务编码：' + serviceCode + '的所有预估单累计验工数量应小于等于本服务所有预估单的累计商合预占数或设计清单数量！',
              type: 'warning'
            })
            return Promise.reject()
          }
          if (onlyBe1Flag === 'N' && allServiceSumNum < 0) {
            this.$message({
              message: '站址编码：' + siteId + '，服务编码：' + serviceCode + '的所有预估单的累计验工数量应大于等于0！',
              type: 'warning'
            })
            return Promise.reject()
          }
      },
      async initDatarepairNine(onlyBe1Flag, allServiceSumNum, minSumNum, siteId, serviceCode) {
        if (allServiceSumNum > minSumNum) {
            this.$message({
              message: '站址编码：' + siteId + '服务编码：' + serviceCode + '的所有预估单累计验工数量应小于等于本服务所有预估单的累计商合预占数或设计清单数量！',
              type: 'warning'
            })
            return Promise.reject()
          }
          if (allServiceSumNum < 0) {
            this.$message({
              message: '站址编码：' + siteId + '，服务编码：' + serviceCode + '的所有预估单的累计验工数量应大于等于0！',
              type: 'warning'
            })
            return Promise.reject()
          }
      },
      async initData(detailFormData) {
        console.log(detailFormData, 'detailFormData')
        var record = detailFormData[0]
          var flag = false
        // 批量新增 三包服务
        /** 三包服务编码只能填写整数
         微站EPC总包服务编码规则：PMS服务编码以90050111开头，但不含9005011109开头服务编码
         微站施工总包服务编码规则：PMS服务编码以90050110开头，但不含9005011009开头服务编码
         新疆机房总承包服务编码规则：9001011008、9002010802、9003010202、9005011010开头的
         */
        // var r = /^[1-9]\d*$/ // 正整数
        var r = /^(?!0\d)\d*$/
        var epcServiceType = record.epcServiceType
        await this.initDatarepairOne(epcServiceType, r, record)
        await this.initDatarepairTwo(epcServiceType, r, record)
        for (var i = 0; i < detailFormData.length; i++) {
          // var pId = detailFormData[i].vid
          var prjId = detailFormData[i].prjId
          var subPrjId = detailFormData[i].subPrjId
          var onlyBe1Flag = detailFormData[i].onlybe1FLAG
          var serviceCode = detailFormData[i].serviceCode
          var siteId = detailFormData[i].siteId
          var currentInspectionMoney = detailFormData[i].currentInspectionMoney
          var currentInspectionNum = detailFormData[i].currentInspectionNum
          // var projectProgress = detailFormData[i].projectProGress
          var sumNum = ''
          var sumMoney = ''
          console.log(sumNum, sumMoney, 'sumNum,sumMoney')
          if (this.newOldProject === '1') { // 老项目的时候onlybe1FLAG校验
          //  if (detailFormData[i].onlybe1FLAG === 'Y') {
          //     sumMoney = this.farmatNum(Number(currentInspectionMoney) + Number(detailFormData[i].sumMoney))
          //     sumNum = 1
          //   } else {
              sumMoney = this.farmatNum(Number(currentInspectionMoney) + Number(detailFormData[i].sumMoney))
              sumNum = this.farmatNum(Number(currentInspectionNum) + Number(detailFormData[i].sumNum))
            // }
          } else {
              sumMoney = this.farmatNum(Number(currentInspectionMoney) + Number(detailFormData[i].sumMoney))
              sumNum = this.farmatNum(Number(currentInspectionNum) + Number(detailFormData[i].sumNum))
          }
          // var shMoney = detailFormData[i].shMoney
          // var shNum = detailFormData[i].shNum

          // var allServiceSumMoney = 0 // 服务所有订单下累计验工金额
          var allServiceSumNum = 0 // 服务所有订单下累计验工数量
          // var allServiceShMoneySum = 0 // 服务所有订单下商合预占金额的和
          var allServiceShNumSum = 0 // 服务所有订单下商合预占数量的和
          var allServiceTServListAmount = 0 // 设计表服务数量
          // var allServiceTServListEquipSum = 0 // 设计表服务及金额
          var allServiceTServListAdjAmount = 0 // 设计变更表服务数量
          // var allServiceTServListAdjEquipSum = 0 // 设计变更表服务及金额
          var allSupplementNum = 0 // 在建工程损失补采数量
          // var minSumMoney = 0
          var minSumNum = 0
          const obj = {
            serviceCode: serviceCode,
            subPrjId: subPrjId,
            prjId: prjId
            }
          const gCheckData = await getCheckInsVaDataNew(obj)
          if (gCheckData.code === '200') {
              // allServiceSumMoney = this.farmatMoney(Number(gCheckData.data.currentInspectionSum.CURRENT_INSPECTION_MONEY_SUM) + Number(currentInspectionMoney))
              allServiceSumNum = this.farmatNum(Number(gCheckData.data.currentInspectionSum.CURRENT_INSPECTION_NUM_SUM) + Number(currentInspectionNum)) // 所有订单累计数量+当前所填本期验工数量
              // allServiceShMoneySum = gCheckData.data.shSum.SH_MONEY_SUM
              allServiceShNumSum = gCheckData.data.shSum.SH_NUM_SUM
              // if (gCheckData.data.supplementNum.SUPPLEMENT_NUM) {
              //   allSupplementNum = gCheckData.data.supplementNum.SUPPLEMENT_NUM // 在建工程损失补采数量
              // }
              allSupplementNum = await this.initDatarepairThree(gCheckData, allSupplementNum)
              // allServiceTServListEquipSum = gCheckData.data.serListSum.SJ_MONEY
              allServiceTServListAmount = gCheckData.data.serListSum.SJ_AMOUNT
              // if (allServiceTServListAmount == null) {
              //   console.log('服务设计表中无站址编码：' + siteId + '，服务编码：' + serviceCode + '的服务数据')
              // }
              allServiceTServListAmount = allServiceTServListAmount + allSupplementNum
            if (this.initDatarepairSix(gCheckData)) { // 设计变更表中有数据已发生设计变更  在商合、设计+补采、设计变更+补采 金额中取最小值
              // allServiceTServListAdjEquipSum = gCheckData.data.serListAdjSum.SERLISTADJEQUIPSUM
              allServiceTServListAdjAmount = gCheckData.data.serListAdjSum.SERLISTADJAMOUNT
              // if (allServiceTServListAdjAmount == null) {
              //   console.log('服务设计变更表中无站址编码：' + siteId + '，服务编码：' + serviceCode + '的服务数据')
              //   }
              allServiceTServListAdjAmount = allServiceTServListAdjAmount + allSupplementNum
              // 商合、设计、设计变更金额取最小值
              minSumNum = await this.initDatarepairFive(allServiceShNumSum, allServiceTServListAmount, allServiceTServListAdjAmount)
            } else {
              minSumNum = await this.initDatarepairFour(minSumNum, allServiceShNumSum, allServiceTServListAmount)
            }
            await this.initDatarepairSeven(onlyBe1Flag, allServiceSumNum, minSumNum, allServiceSumNum, siteId, serviceCode)
          }
        }

        this.initSaveDataBefore(detailFormData)
      },
      async initSaveDataBefore(detailFormData) {
        var resultsFlag = true
        for (var i = 0; i < detailFormData.length; i++) {
            var pId = detailFormData[i].vid
            var prjId = detailFormData[i].prjId
            var subPrjId = detailFormData[i].subPrjId
            var onlyBe1Flag = detailFormData[i].onlybe1FLAG
            var serviceCode = detailFormData[i].serviceCode
            var siteId = detailFormData[i].siteId
            var currentInspectionMoney = detailFormData[i].currentInspectionMoney
            var currentInspectionNum = detailFormData[i].currentInspectionNum
            var projectProgress = detailFormData[i].projectProGress
            var sumMoney = ''
            var sumNum = ''
            if (this.newOldProject === '1') { // 老项目的时候onlybe1FLAG校验
              // if (detailFormData[i].onlybe1FLAG === 'Y') {
              //   sumMoney = this.farmatNum(Number(currentInspectionMoney) + Number(detailFormData[i].sumMoney))
              //   sumNum = 1
              // } else {
                sumMoney = this.farmatNum(Number(currentInspectionMoney) + Number(detailFormData[i].sumMoney))
                sumNum = this.farmatNum(Number(currentInspectionNum) + Number(detailFormData[i].sumNum))
              // }
            } else {
                sumMoney = this.farmatNum(Number(currentInspectionMoney) + Number(detailFormData[i].sumMoney))
                sumNum = this.farmatNum(Number(currentInspectionNum) + Number(detailFormData[i].sumNum))
            }
            // var shMoney = detailFormData[i].shMoney
            // var shNum = detailFormData[i].shNum
            var taxrate = detailFormData[i].taxrate
            var inspectionTax = Number(currentInspectionMoney) * Number(taxrate) // 验工计价税额 = 本期验工金额*税率
            inspectionTax = this.farmatMoney(inspectionTax)
            var inspectionTaxAmount = this.farmatMoney(Number(currentInspectionMoney) + Number(inspectionTax)) // 含税验工计价总金额 = 本期验工金额 + 验工计价税额
            var orderDetailId = detailFormData[i].orderDetailId
            var purchaseMode = detailFormData[i].purchaseMode
            var payType = detailFormData[i].payType
            var data = { pId: pId, prjId: prjId, subPrjId: subPrjId, onlyBe1Flag: onlyBe1Flag, siteId: siteId,
                        serviceCode: serviceCode,
                        currentInspectionNum: currentInspectionNum, currentInspectionMoney: currentInspectionMoney,
                        sumMoney: sumMoney, sumNum: sumNum, projectProgress: projectProgress, inspectionTax: inspectionTax,
                        inspectionTaxAmount: inspectionTaxAmount, orderDetailId: orderDetailId, purchaseMode: purchaseMode,
                        payType: payType, flag: '1', oldSumMoney: this.oldSumMoney, oldSumNum: this.oldSumNum
						}
            // this.initSaveData(data)
          var resultsError = ''
          const gCheckData = await updateInsVaDetailsNew(data)
          if (gCheckData.code === '200') {
            if (gCheckData.message !== '操作成功') {
                  resultsFlag = false
                  resultsError = resultsError + '站址编码：' + data.siteId + '，服务编码：' + data.serviceCode + '，保存失败;'
            }
          }
        }
        if (resultsFlag) {
              this.$message({
                message: '保存成功！',
                type: 'success'
              })
              this.fomrDialogVisible = false // 批量新增验工计价展示
              // this.dialogClosed() // 外部关闭弹框
              this.listData()
          } else {
            this.$message({
                message: resultsError,
                type: 'warning'
              })
          }
      },
      // 将弹框挂载在最外层
      dialogEl(refName) {
          // 将弹框挂载在最外层
          const contentBody = window.top.document.body
          this.$nextTick(() => {
              const dialogModal = document.querySelector('.v-modal')
              contentBody.appendChild(this.$refs[refName].$el)
              contentBody.appendChild(dialogModal)
              disableScroll(contentBody)
          })
      },
      // 关闭弹框
      dialogClosed() {
          const contentBody = window.top.document.body
          enableScroll(contentBody)
      },
      // 项目编码跳转新页面
      async skipPage(subPrjCode) {
          const res = await getShopTokenAndUrlNew({ sysCode: 'CHNTBP', prjCode: subPrjCode })
            if (+res.code === 200) {
                const data = res.data
                const toUrl = `${data.assetsResource.transactionUrl}eshop/pending/universal/sso.do?url=/v2/stage/front/index.html#/pmsEstimate?projectCode=${data.prjCode}&projectType=${data.manageMode}`
                const params = {}
                params.token = data.assetsResource.token
                params.acctId = data.assetsResource.acctId
                params.userName = data.assetsResource.userId
                const newWin = window.open()
                const form = $("<form method='post'></form>")
                form.attr({ action: toUrl })
                $.each(params, function(key, value) {
                    const input = $("<input type='hidden' >")
                    input.attr({ name: key })
                    input.val(value)
                    form.append(input)
                })
                form.appendTo(newWin.document.body)
                form.submit()
            }
      }
    }
  }
  </script>
  <style scoped>
  .colorRed{
        color:red;
    }
    .el-upload--text {
      width: 100%;
    }
    .btnflex{
      display: flex;
      justify-content: space-between;
    }
    .el-table th {
      padding: 0px 0;
      text-align: center;
      font-size: 12px;
      color: #333333;
      letter-spacing: 0;
    }
    .el-table td {
      padding: 0px 0;
      text-align: center;
      font-size: 2px;
      color: #333333;
      letter-spacing: 0;
    }
    /* /deep/.el-table__header-wrapper .cell .el-checkbox {
        display: none;
    } */
    /* ::v-deep .el-form-item { */
       /* width: 45%; */
       /* text-align: center; */
    /* } */
    .formBott{
        text-align: center;
        /* margin-top: 30px; */
    }
    /* ::v-deep .el-input__suffix{
        margin-top:9px
    } */
  .el-collapse {
      margin-bottom: 15px;
  }
  .el-collapse-item {
      box-shadow: 0px 0px 6px 0px rgba(191, 192, 192, 0.52);
      /* 调整各个item之间的距离为20px */
      /* border: 1px; */
  }

  .el-collapse-item__wrap {
      padding: 0 20px;
      /* 为el-collapse-item的内容添加20像素的padding */
  }

  .el-collapse-item__header {
      padding-left: 20px;
      font-size: 14px;
      color: #333333;
      letter-spacing: 0;
      font-weight: 600;
  }

  .item_icon {
      width: 6px;
      background: rgb(235, 75, 75);
      height: 15px;
      margin-right: 10px;
      border-radius: 10px;
  }

  .content-box {
      width: 100%;
      border-radius: 3px;
      font-size: 12px;
      font-weight: 400;
      line-height: 25px;
  }

  .header-tooltip {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #messBox {
      word-break: break-all;
    }
  </style>

